Features:
- Additional rules may now be shipped as gems. Files matching the path
foodcritic/rules/**/*.rb
will be loaded if the--search-gems
option is specified (related issue). Thanks to @rteabeault for implementing this feature. - You can now control the rules applied to individual cookbooks by including
a
.foodcritic
file at the root of your cookbook with the tags you want checked (related issue). Thanks to @sabat for implementing this feature. - The project license is now included in the built gem (related issue). Thanks @stefanor.
- Foodcritic no longer uses the
rak
gem to generate output with context (related issue). Thanks to @stefanor for re-implementing context output to remove this dependency. - A man page is now included with foodcritic in ronn-format. Thanks @stefanor.
Bugfixes:
- Definitions are now included in the files that are linted (related issue). Thanks @bpaquet.
- FC009: Resource attribute not recognised would warn against Windows-specific resource attributes (related issue). Thanks @stormtrooperguy.
- FC011: Missing README in markdown format was not shown when outputting with context enabled (related issue). Thanks @stefanor.
- FC014: Consider extracting long ruby_block to library previously used the number of AST nodes to determine block length. This was a poor proxy for length and this rule has been updated to warn if the number of lines > 15 (related issue). Thanks @adamjk-dev.
- FC014: Consider extracting long ruby_block to library would warn against other blocks incorrectly (related issue). Thanks @adamjk-dev.
- FC014: Consider extracting long ruby_block to library
would raise an error if the ruby_block did not contain a nested
block
attribute (related issue). Thanks @stevendanna. - FC033: Missing template would warn when the template file did not have an erb extension (related issue). Thanks @nvwls.
- FC034: Unused template variables would warn when the template file did not have an erb extension (related issue). Thanks @nvwls.
Features:
- DSL metadata will now reflect the version of Chef selected with
--chef-version
. For example this means that FC009: Resource attribute not recognised will warn about attributes not present in the specified version of Chef.
Bugfixes:
- FC045: Consider setting cookbook name in metadata would warn incorrectly and other rules would fail to work when activesupport had been loaded (related issue). This affected Berkshelf users. Thanks @scalp42 and @c-nolic.
- Upgrade the version of Gherkin dependency to avoid deprecation warnings (related issue). Thanks @tmatilai.
Other:
- Known to run on MRI 2.0.0 - added to Travis CI matrix.
Bugfixes:
- Matches that should be ignored were not if the rule implementation used the
cookbook
block (related issue). - FC033: Missing Template would warn incorrectly when the template resource was nested within another resource (related issue). Thanks @justinforce.
- The
#resource_attributes
API method now copes with nested resources.
Features
- Support added for ignoring individual matches. To ignore a match add a
comment to the affected line in your cookbook of the format
# ~FC006
(related issue). Big thanks to @grosser. - Command line help now specifies the tag to use to fail the build on any rule match (related issue). Thanks @grosser.
- FC046: Attribute assignment uses assign unless nil rule added (related issue). Thanks @jaymzh.
Bugfixes:
- FC003: Check whether you are running with chef server before using server-specific features updated to recognise checks that use return (related issue). Thanks @sethvargo, @miketheman.
- FC003: Check whether you are running with chef server before using server-specific features updated to recognise checks that test for Chef Solo with alternation (related issue). Thanks @promisedlandt.
- FC017: LWRP does not notify when updated modified to no longer warn when a notification is made without parentheses (related issue). Thanks @justinforce.
- FC019: Access node attributes in a consistent manner would previously only show warnings for the first matching file.
- FC019: Access node attributes in a consistent manner updated to avoid showing a false positive where a search is passed an argument based on a node attribute accessed with a string.
- FC019: Access node attributes in a consistent manner updated to exclude specs, removing a source of false positives.
- FC019: Access node attributes in a consistent manner fixed regression in var_ref handling.
- FC019: Access node attributes in a consistent manner updated to not trigger on quoted symbols (related issue). Thanks @spheromak.
- FC024: Consider adding platform equivalents updated to only warn about platform equivalents that are listed in the cookbook metadata (related issue). Thanks @tknerr.
- FC037: Invalid notification action would cause foodcritic to halt with an error when a notification action was specified as an expression (related issue). Thanks @jaymzh.
- FC040: Execute resource used to run git commands
updated to not match if the git command cannot be expressed as a
git
resource. (related issue). Thanks @trobrock for raising this issue and implementing the fix. - FC043: Prefer new notification syntax updated to apply only to Chef versions >= 0.9.10 (related issue). Thanks @iainbeeston.
- FC044: Avoid bare attribute keys changed to not raise false positives against block variables (related issue). Thanks @jaymzh.
Other:
- The
--repl
command line flag has been removed. This feature little used and was problematic for users attempting to use newer versions of pry or guard (related issue). Thanks @jperry, @miketheman, @jtimberman. - The
os_command?
api method has been removed. - The deprecated
cookbook_path
andvalid_path?
methods have been removed. This may cause breakage if you are using foodcritic programatically from Ruby. Please update your code to use thecookbook_paths
andvalid_paths?
methods instead. - Added regression test for expected output against opscode-cookbooks. Run
bundle exec rake regressions
to perform this test.
Features
- FC038: Invalid resource action rule added (related issue). Thanks @jaymzh.
- FC039: Node method cannot be accessed with key rule added.
- FC040: Execute resource used to run git commands rule stolen from Etsy rules (ETSY003) (related issue). Thanks @jonlives.
- FC041: Execute resource used to run curl or wget commands rule stolen from Etsy rules (ETSY002) (related issue). Thanks @jonlives.
- FC042: Prefer include_recipe rule added (related issue). Thanks @pwelch.
- FC043: Prefer new notification syntax rule added (related issue). Thanks @jtimberman.
- FC044: Avoid bare attribute keys rule added (related issue). Thanks @jtimberman.
- FC045: Consider setting cookbook name in metadata rule added (related issue). Thanks @miketheman.
- Linter
#check
method no longer requires options to be explicitly passed if you are using the defaults (related issue). Thanks @kreynolds.
Bugfixes:
- Bump version of Nokogiri to fix installation failure on Ubuntu 12.10 (related issue). Thanks @dracoater.
- Support added for quoted symbols as notification actions (related issue). Thanks @ohm.
- Add
spec/**/*
andfeatures/**/*
to default rake task:exclude_paths
(related issue). Thanks @fnichol. - Remove unnecessary whitespace from rake task output (related issue). Thanks @ketan.
- Removed FC001: Use strings in preference to symbols to access node attributes (related issue). Thanks @jtimberman.
- FC003: Check whether you are running with chef server before using server-specific features
updated to also match
unless
(related issue). Thanks @cap10morgan. - Decode numeric attributes. This could cause FC005: Avoid repetition of resource declarations to warn incorrectly (related issue). Thanks @masterkorp.
- Recognise attributes correctly within a block. This could cause FC005: Avoid repetition of resource declarations to warn incorrectly (related issue). Thanks @masterkorp.
- FC009: Resource attribute not recognised would warn incorrectly on methods used within a resource block (related issue). Thanks @arangamani.
- FC019: Access node attributes in a consistent manner would warn incorrectly when referencing node attributes from a user-created hash. (related issue). Thanks @schubert.
- FC033: Missing Template would warn incorrectly when using templates from another cookbook (related issue). Thanks @woohgit.
Bugfixes:
- FC030: Cookbook contains debugger breakpoints could prevent other rules from processing depending on the tags passed.
- FC037: Invalid notification action
would incorrectly warn against
subscribes
notifications (related issue). Thanks @jtimberman.
Bugfixes:
- Removed FC035: Template uses node attribute directly. For a discussion of the reasons for removal see the related issue.
Bugfixes:
- Remove pry-doc dependency to resolve pry version conflict.
Features:
- FC033: Missing template rule added.
- FC034: Unused template variables rule added (related issue).
- FC035: Template uses node attribute directly rule added. This is a style rule that may prove controversial.
- FC037: Invalid notification action rule added.
- The
#read_ast
API method now supports Erb templates. - API method
#resource_action?
added. - DSL extended to include
library
,metadata
andtemplate
.
Bugfixes:
- FC020: Conditional execution string attribute looks like Ruby rule has been removed as unreliable.
- The
#attribute_access
API method now correctly allows a type of:any
. - The
#notifications
API method now supports notifications enclosed in braces (related issue). - Ensure command-line help is shown when an invalid option is passed. Thanks to @juanje for finding and fixing this issue.
Features:
- FC027: Resource sets internal attribute rule added. Thanks @macros.
- FC028: Incorrect #platform? usage rule added.
- FC029: No leading cookbook name in recipe metadata rule added.
- FC030: Cookbook contains debugger breakpoints rule added (related issue). Thanks @bryanwb.
- FC031: Cookbook without metadata file rule added (related issue). Thanks to @juanje for proposing and implementing this rule.
- FC032: Invalid notification timing rule added.
- Added the notifications API method to provide more convenient access to resource notifications (related issue).
Bugfixes:
- FC003: Check whether you are running with chef server before using server-specific features
would warn if solo was checked for with
Chef::Config.solo
(related issue). Thanks to @miketheman for identifying and fixing this issue. - FC007: Ensure recipe dependencies are reflected in cookbook metadata
would incorrectly warn if the cookbook name specified for
include_recipe
was dynamic (related issue). Thanks @markjreed. - FC019: Access node attributes in a consistent manner has been modified to no longer warn if the method called on node is called explicitly with brackets (related issue). Thanks @jaymzh.
- The resource_attributes API method has been updated to return boolean values correctly.
Bugfixes:
- Changes made to support multiple cookbook paths in 1.3.0 broke
compatibility with earlier versions of the linting API. This release
restores compatibility with third party code that uses the linter
#cookbook_path
or#valid_path?
methods. - The Nokogiri dependency constraint has been locked to 1.5.0 again as Nokogiri 1.5.3 also appears to segfault in certain circumstances.
Features:
- FC026: Conditional execution block attribute contains only string rule added (related issue). Thanks to @mkocher for proposing this rule.
- Foodcritic now accepts multiple cookbook paths as arguments and supports linting of individual files only. Big thanks to @cgriego for these changes. These lay the groundwork for his new guard-foodcritic project.
Bugfixes:
- FC003: Check whether you are running with chef server before using server-specific features would still warn if solo was checked for as a string (related issue). Thanks to @miketheman for identifying and fixing this issue.
- FC019: Access node attributes in a consistent manner would warn when the node object had been re-opened for extension (related issue). Thanks @jaymzh.
- FC020: Conditional execution string attribute looks like Ruby
updated to not warn against strings that appear to contain file paths or Windows
net use
(related issue). Thanks @eherot and @mconigliaro. - FC022: Resource condition within loop may not behave as expected would warn incorrectly if the resource name was set directly to the block variable rather than being a string expression (related issue). Thanks @eherot.
- The resource_attributes API method has been updated to return the AST for resource notifications (related issue). Thanks @jonlives.
Other:
- Etsy have open-sourced their Foodcritic rules. You should definitely check these out.
- The effective Chef version for determining the rules to apply has been bumped to 0.10.10.
Features:
- FC025: Prefer chef_gem to compile-time gem install rule added.
- Rules can now declare which versions of Chef they
apply_to
. The new command line argument-c
(--chef-version
) should be used to specify the effective Chef version.
Bugfixes:
- FC001: Use strings in preference to symbols to access node attributes could show false positives when using Chef search.
- FC001: Use strings in preference to symbols to access node attributes would overlook the use of symbols to access node attributes when passing template variables.
- FC002: Avoid string interpolation where not required fixed to no longer ignore the first keypair in a Hash (related issue). Thanks @Ips1975.
- FC004: Use a service resource to start and stop services
modified not to warn if the action is not supported by the
service
resource. - FC005: Avoid repetition of resource declarations modified not to warn when resources are branched within conditionals or provider actions.
- FC007: Ensure recipe dependencies are reflected in cookbook metadata
modified to ignore the use of
include_recipe
with embedded expressions. - FC023: Prefer conditional attributes
modified not to warn if the conditional expression has an
else
. - The
resource_attributes
API method has been updated to return block attributes which were previously ignored (related issue). Thanks @jonlives.
Features:
- FC024: Consider adding platform equivalents rule added.
- When writing new rules it is no longer necessary to explicitly map matching AST nodes to matches. You can now just return the AST nodes.
Bugfixes:
- The
cookbook_name
method now reflects the cookbook name if specified in metadata. This prevents a warning from being shown by FC007: Ensure recipe dependencies are reflected in cookbook metadata if the cookbook is in a differently named directory. - The
declared_dependencies
method previously would intermix version strings in the list of cookbook names.
Other:
- Chef 0.10.10 will include a new DSL method for defining a
default_action
for resources. Rule FC016: LWRP does not declare a default action has been updated to recognise the DSL change. - Nokogiri dependency constraint changed to no longer lock to 1.5.0 as their next release should include the fix for custom XPath functions.
Bugfixes:
- Nokogiri 1.5.1 and 1.5.2 cause a segfault so prevent their use until a fix is released (related issue). Thanks @miah.
Features:
- New
-I
option added to specify the path to your own custom rules (related issue). - The Rule API was previously not supported and subject to change without warning. From this release it will now follow the same versioning policy as the command line interface.
- A version flag (--version or -V) has been added (related issue).
Bugfixes:
- The evaluation of rule tags has been updated to be consistent with Cucumber. The major version number of foodcritic has been bumped to indicate that this is a breaking change. If you make use of tags (for example in a CI build) you may need to update your syntax. See the related issue for more information. Thanks @jaymzh.
- FC003: Check whether you are running with chef server before using server-specific features has been updated to correctly identify the new version of chef-solo-search (related issue).
Bugfixes:
- Foodcritic could fail to activate yajl-json in some circumstances, failing with a runtime error. Whether this occurred was dependent on the version of yajl-ruby activated by Chef, which would vary dependent on the other gems installed on the system. See the related issue for more information. Thanks @jaymzh for identifying the issue and striving to get Foodcritic playing well with Omnibus.
Bugfixes:
- Major bugfix to FC006: Mode should be quoted or fully specified when setting file permissions. In earlier versions a four-digit literal file mode that set the first octet would not have been picked up by this rule (related issue). Thanks @aia for finding and fixing this bug. Check your cookbooks against FC006 after upgrading to see if you are affected.
Features:
- Performance improvements.
- FC023: Prefer conditional attributes rule added. Stolen from @ampledata with thanks.
- New
-S
option added to allow an alternate search grammar to be specified.
Other:
- Chef is no longer loaded at startup for performance reasons. Foodcritic now ships with Chef DSL metadata.
Features:
- New experimental
-C
option added to output context for rule matches. - FC021: Resource condition in provider may not behave as expected rule added.
- FC022: Resource condition within loop may not behave as expected rule added.
Bugfixes:
- FC005: Avoid repetition of resource declarations rule modified to only warn when there are at least three consecutive resources of the same type that could be 'rolled up' into a loop.
- FC016: LWRP does not declare a default action rule restored. Thanks @stevendanna
- FC019: Access node attributes in a consistent manner rule modified to no longer treat DSL mixin methods as auto-vivified attributes. Identification of least used access method should now be accurate.
Other:
- FC020: Conditional execution string attribute looks like Ruby rule now grabs conditions from within single quotes.
Bugfixes:
- FC019: Access node attributes in a consistent manner modified to avoid false positives on methods invoked on values in a Mash.
Features:
- FC019: Access node attributes in a consistent manner rule added.
- FC020: Conditional execution string attribute looks like Ruby rule added.
Other:
- Rule 'FC016: LWRP does not declare a default action' was incorrectly checking the provider for a default action rather than the resource. Removed this rule temporarily to avoid showing false positives. A user has patched this and will be submitting a pull request shortly.
Features:
- New
-f
option added to allow you to specify which warnings should result in the build being failed. See the new documentation on using Foodcritic in Continuous Integration for more information. - New
-r
option added to drop you into the Pry REPL to interactively develop rules. See the updated documentation on Writing a new rule for more information.
Bugfixes:
- FC003: Check whether you are running with chef server before using server-specific features rule modified to not warn if the edelight chef-solo-search library has been installed. Thanks @tobami.
- FC007: Ensure recipe dependencies are reflected in cookbook metadata rule modified to flag undeclared dependencies against the offending file rather than metadata.rb.
- Removed the unused description field from the rule dsl.
Other:
- Project features now run much faster, running in-process by default. You can set an environment variable
(
FC_FORK_PROCESS
) to specify that Cucumber runs should match the earlier behaviour and spawn a separate process using Aruba.
Features:
- FC001: Use strings in preference to symbols to access node attributes rule added.
- FC004: Use a service resource to start and stop services rule extended to recognise upstart and invoke-rc.d.
- FC011: Missing README in markdown format rule added.
- FC012: Use Markdown for README rather than RDoc rule added.
- FC013: Use file_cache_path rather than hard-coding tmp paths rule added.
- FC014: Consider extracting long ruby_block to library rule added.
- FC015: Consider converting definition to a LWRP rule added.
- FC016: LWRP does not declare a default action rule added.
- FC017: LWRP does not notify when updated rule added.
- FC018: LWRP uses deprecated notification syntax rule added.
Bugfixes:
- Ensure warnings are line sorted numerically. Commit eb1762fd0fbf99fa513783d7838ceac0147c37bc
- FC005: Avoid repetition of resource declarations rule made less aggressive.
Bugfixes:
- Fix JSON version range for compatibility with Bundler / Chef 0.10.6. (related issue). Thanks @dysinger.
Features:
- Relaxed Ruby version constraint so we can run on 1.9.2 (related issue). Yay. Thanks @someara.
Features:
- Added the ability to choose rules to apply via tags (related issue). This uses the same syntax as Cucumber tag expressions.
- FC010: Invalid search syntax rule added.
Features:
- Spiffy new home page and documentation
- FC008: Generated cookbook metadata needs updating rule added.
- FC009: Resource attribute not recognised rule added. This adds a dependency on the Chef gem.
- Performance improvement.
Bugfixes:
- Fixed typo in FC004 feature description (related issue). Thanks @smith.
- Prevented statements within nested resource blocks from being interpreted as resource attributes.
Features:
- Significantly slower! But now you can write rules using xpath or css selectors.
- FC006: File mode rule added.
- FC007: Undeclared recipe dependencies rule added.
Bugfixes:
- Removed 'FC001: Use symbols in preference to strings to access node attributes' until a policy mechanism is introduced (related issue). Thanks @jtimberman
Initial version.