A linting tool that helps you to write better Chef Infra cookbooks and InSpec profiles by detecting and automatically correcting style, syntax, and logic mistakes in your code.
Apache License 2.0
107
stars
54
forks
source link
Support for `depends` with missing comma in metadata instead of `Lint/ImplicitStringConcatenation` #878
[ ] Chef/Deprecations - A cop that alerts on a deprecation in the Chef Infra Client
[X] Chef/Correctness - A cop that alerts when incorrect coding behavior is being used
[ ] Chef/Sharing - A cop that alerts to missing functionality necessary for sharing cookbooks with others
[ ] Chef/Style - A cop that alerts to a style best practice
[ ] Chef/Modernize - A cop that alerts when a cookbook can be simplified or modernized with new functionality
[ ] Chef/Effortless - A cop that alerts on code that must be resolved to move to the Effortless pattern
[ ] Chef/RedundantCode - A cop that detects redundant code regardless of Chef Infra release
[ ] InSpec/Deprecations - A cop that alerts on a deprecation in the Chef InSpec
Describe the new cop:
When running cookstyle against a local cookbook repository that has incorrectly-formatted depends lines which are missing a comma, Cookstyle will report the failure as Lint/ImplicitStringConcatenation. Suggestion for new feature is that we detect Lint/ImplicitStringConcatenation for depends lines in metadata.rb and suggest how it is supposed to be represented and auto-correct.
# Cookstyle report
$ cookstyle
Inspecting 4 files
.W..
Offenses:
metadata.rb:9:9: W: Lint/ImplicitStringConcatenation: Combine 'some_awesome_cookbook' and '=4.5.5' into a single string literal, rather than using implicit string concatenation. Or, if they were intended to be separate method arguments, separate them with a comma.
depends 'some_awesome_cookbook' '= 4.5.5'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
metadata.rb:10:9: W: Lint/ImplicitStringConcatenation: Combine 'some_other_cool_cookbook' and '< 8.0' into a single string literal, rather than using implicit string concatenation. Or, if they were intended to be separate method arguments, separate them with a comma.
depends 'some_other_cool_cookbook' '< 8.0'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 files inspected, 2 offenses detected
What category of cop is this?:
Please try to select as few as possible.
Describe the new cop:
When running
cookstyle
against a local cookbook repository that has incorrectly-formatteddepends
lines which are missing a comma, Cookstyle will report the failure asLint/ImplicitStringConcatenation
. Suggestion for new feature is that we detectLint/ImplicitStringConcatenation
fordepends
lines in metadata.rb and suggest how it is supposed to be represented and auto-correct.What it would trigger on:
What it would autocorrect to if applicable
Can We Help You Implement This?:
I'm not sure what the best Cop section/name would be for something like this so I didn't suggest one 😁