With codeqa you can check your code to comply to certain coding rules (utf8 only chars, indenting) or to avoid typical errors or enforce deprecations. You might even put it into a pre commit hook.
Add this line to your application's Gemfile:
gem 'codeqa'
And then execute:
$ bundle
Or install it yourself as:
$ gem install codeqa
codeqa filename
Since Version 0.3 codeqa uses ruby for configuration, therefore the config file
is now named .codeqa.rb
. The loading of configuration files is still the same,
meaning we have to following load order:
- Initialize with default settings (see
config/default.rb
) - load
.codeqa/config.rb
from your home directory and merge it with the defaults. - load
.codeqa/config.rb
placed in the project root, which is determined by finding the closest.git
folder.
Both the config in your home directory and the project config file are optional and will be automatically skiped if they do not exist.
Because codeqa now uses ruby for configuration we can more easily change settings without replacing it completely.
Codeqa.configure do |config|
# override the list of excludes
config.excludes = ['coverage/*',
'pkg/*',
'tmp/*',
/\.log/]
# remove the default ruby lint in favor of rubocop
config.enabled_checker.delete 'CheckRubySyntax'
config.enabled_checker << 'RubocopLint'
# also enable the rubocop autoformatter
config.enabled_checker << 'RubocopFormatter'
# add some more active formatters/cops to rubocop
config.rubocop_formatter_cops << 'AlignHash'
config.rubocop_formatter_cops << 'SignalException'
config.rubocop_formatter_cops << 'DeprecatedClassMethods'
config.rubocop_formatter_cops << 'RedundantBegin'
config.rubocop_formatter_cops << 'RedundantSelf'
config.rubocop_formatter_cops << 'RedundantReturn'
config.rubocop_formatter_cops << 'CollectionMethods'
end
- pattern
- CheckPry
- CheckRspecFocus
- CheckConflict
- CheckStrangeChars
- CheckLinkTo
- rubocop
- RubocopLint (replacement for CheckRubySyntax)
- RubocopFormatter
- erb
- CheckErb (tests erb template for syntax errors using either
erb
oraction_view
- CheckErbHtml (removes all erb tags and tests with
tidy
if the template is valid XML) - HtmlValidator (uses Nokogiri to check stripped html.erb files against XML errors)
- CheckErb (tests erb template for syntax errors using either
- yard
- CheckYard (checks YARD for warnings)
- CheckRubySyntax (runs file though
ruby -c
, use RubocopLint if possible)
Since version 0.5 it's possible to run any scripts which are placed at .codeqa/hooks . If they exit with code <> 0 the commit is not allowed. The scripts have to be executable.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request