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

Add the ability to run custom rules included in a project #19

Closed
wants to merge 2 commits into from
Closed

Add the ability to run custom rules included in a project #19

wants to merge 2 commits into from

Conversation

pdericson
Copy link
Contributor

This is a little rough but I figured I'd raise it now to gauge interest.

@coveralls
Copy link

coveralls commented Sep 22, 2016

Coverage Status

Coverage decreased (-0.3%) to 98.041% when pulling 0b985a0 on pdericson:custom_rules into 9b72a2d on adrienverge:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 98.041% when pulling 0b985a0 on pdericson:custom_rules into 9b72a2d on adrienverge:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 98.041% when pulling 0b985a0 on pdericson:custom_rules into 9b72a2d on adrienverge:master.

@coveralls
Copy link

coveralls commented Sep 22, 2016

Coverage Status

Coverage increased (+0.1%) to 98.502% when pulling 47dafd9 on pdericson:custom_rules into 9b72a2d on adrienverge:master.

@adrienverge
Copy link
Owner

Hey @pdericson,

Nice work!

Although the idea of "pluggable rules" looks good, I don't like yamllint automatically loading rules from the current dir. This would allow untrusted sources (example: a pull request on GitHub) to run arbitrary Python code. Maybe a --plugin option would be better? And it would allow pluggable rules installed system-wide.

Could you give more details about your use-case? Is the "truthy" rule just an example, or something you really want to lint?

@pdericson
Copy link
Contributor Author

Hey @adrienverge, I'll rework my PR to make this explicitly opt-in like you suggest. Regarding the "truthy" example - I have been thinking about creating an ansible linter for a while and so this example would be something I'd like to include.

@adrienverge
Copy link
Owner

Hi @pdericson,

I can see the use of such a rule!

I guess the motivation is to prevent pyyaml from altering YAML source. Because by default, it turns

1: y
2: yes
3: on
4: true
5: True

into

{
    "1": "y", 
    "2": true, 
    "3": true, 
    "4": true, 
    "5": true
}

and

y:    1
yes:  2
on:   3
true: 4
True: 5

into

{
    "y": 1, 
    "true": 5
}

To be honest I don't really like the pluggable rules idea, but I would warmly welcome a quote-truthy rule contribution!

@pdericson
Copy link
Contributor Author

@adrienverge I agree, so far the only yaml linting idea I have had for ansible is the truthy rule which as you have pointed out can be made generic.

I'm going to replace this PR with #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants