Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Custom reference.conf #6

Closed
sleepo581 opened this issue May 5, 2022 · 4 comments
Closed

[QUESTION] Custom reference.conf #6

sleepo581 opened this issue May 5, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@sleepo581
Copy link
Contributor

Hi. I like the plugin and want to use it in my project, however I need to reconfigure the rules.
I have found out that it's difficult to configure a few rules in pom.xml, for ex. "M010" from zally ruleset.

Is there a possibility to set a link to custom reference.conf?
This file is like a centralised place for almost all rules (both zalando and zally) and I think it may be convenient to configure rules through it.

@sleepo581
Copy link
Contributor Author

For now I'm using the following config, but it looks awkward 😄

<ruleConfigs>
    <CaseChecker>
        {
            cases: {
                camelCase: "[a-z][a-z0-9]*(?:[A-Z0-9]+[a-z0-9]*)*",
                PascalCase: "[A-Z]+[a-z0-9]*(?:[A-Z0-9]+[a-z0-9]*)*",
                snake_case: "[a-z][a-z0-9]*(?:_[a-z0-9]+)*",
                SCREAMING_SNAKE_CASE: "[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*",
                "kebab-case": "[a-z][a-z0-9]*(?:-[a-z0-9]+)*",
                "COBOL-CASE": "[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*",
                "hyphenated-Camel-Case": "[a-z][a-z0-9]*(?:-[A-Z0-9]+[a-z0-9]*)*",
                "Hyphenated-Pascal-Case": "[A-Z]+[a-z0-9]*(?:-[A-Z0-9]+[a-z0-9]*)*",
                "Title Case": "([A-Z][^\\s]*\\s?)+"
            },
            pathSegments: {
                allow: [
                    "[a-z][a-z0-9]*(?:-[a-z0-9]+)*"
                ]
            },
            propertyNames: {
                allow: [
                    "[a-z][a-z0-9]*(?:[A-Z0-9]+[a-z0-9]*)*"
                ]
            },
            pathParameterNames: {
                allow: [
                    "[a-z][a-z0-9]*(?:-[a-z0-9]+)*",
                    "[a-z][a-z0-9]*(?:_[a-z0-9]+)*"
                ]
            },
            queryParameterNames: {
                allow: [
                    "[a-z][a-z0-9]*(?:_[a-z0-9]+)*"
                ]
            },
            headerNames: {
                allow: [
                    "[A-Z]+[a-z0-9]*(?:-[A-Z0-9]+[a-z0-9]*)*"
                ]
            },
            tagNames: {
                allow: [
                    "([A-Z][^\\s]*\\s?)+"
                ]
            },
            discriminatorValues: {
                allow: [
                    "[a-z][a-z0-9]*(?:_[a-z0-9]+)*"
                ]
            },
            enumValues: {
                allow: [
                    "[a-z][a-z0-9]*(?:_[a-z0-9]+)*"
                ]
            }
        }
    </CaseChecker>
</ruleConfigs>

@ethlo
Copy link
Owner

ethlo commented May 6, 2022

Thanks for your interest! I will have a look at this and see what is possible to override.

@sleepo581
Copy link
Contributor Author

Hi @ethlo . I've created a pull request that adds possibility to set link to a custom config file for rules like this one:
https://github.com/zalando/zally/blob/main/server/zally-ruleset-zalando/src/main/resources/reference.conf
Rule configs are evaluated in the following order:

  1. Rule configurations defined in ruleConfig
  2. Rules configurations defined in file rulesConfigLocation
  3. Default rules configurations taken from classpath (eg. reference.conf in Zalando library)

@ethlo ethlo closed this as completed in db934b1 May 14, 2022
@ethlo
Copy link
Owner

ethlo commented May 14, 2022

Thanks for the effort! PR merged 👍🏻

@ethlo ethlo added this to the 1.1.0 milestone May 14, 2022
@ethlo ethlo added the enhancement New feature or request label May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants