diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..c658c1c --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,73 @@ +require: + - rubocop-performance + +AllCops: + TargetRubyVersion: 2.4 + NewCops: enable + DisplayCopNames: true + +Layout/AccessModifierIndentation: + EnforcedStyle: outdent + +Layout/LineLength: + Max: 80 + +# I return a nil value in the beginning of setter +# to write it in a single line: +# +# def foo=(value) +# return @foo = nil if value.blank? +# # ... +# end +# +Lint/ReturnInVoidContext: + Enabled: false + +Metrics/ClassLength: + Max: 200 + +Performance/MethodObjectAsBlock: + Enabled: false + +# Performance/RedundantStringChars: +# Enabled: false + +Style/AndOr: + EnforcedStyle: conditionals + +Style/ArrayCoercion: + Enabled: false + +Style/AsciiComments: + Enabled: false + +Style/DoubleNegation: + Enabled: false + +Style/HashAsLastArrayItem: + Enabled: false + +Style/MixinUsage: + Exclude: + - 'bin/console' + +Style/PerlBackrefs: + Enabled: false + +Style/RegexpLiteral: + Enabled: false + +Style/RescueStandardError: + EnforcedStyle: implicit + +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: comma + +Style/VariableInterpolation: + Enabled: false diff --git a/Rakefile b/Rakefile index 7398a90..0a7f455 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,16 @@ # frozen_string_literal: true require 'bundler/gem_tasks' + +desc 'Run code analysis tools (RuboCop...)' +task lint: :rubocop + +desc 'Fix code style (rubocop --auto-correct)' +task fix: 'rubocop:auto_correct' + +begin + require 'rubocop/rake_task' + RuboCop::RakeTask.new +rescue LoadError + nil +end diff --git a/digest-keccak.gemspec b/digest-keccak.gemspec index 9032300..e4847ea 100644 --- a/digest-keccak.gemspec +++ b/digest-keccak.gemspec @@ -47,6 +47,8 @@ Gem::Specification.new do |spec| spec.extensions << 'ext/digest/extconf.rb' - spec.add_development_dependency 'bundler', '~> 2.2' - spec.add_development_dependency 'rake', '~> 13.0' + spec.add_development_dependency 'bundler', '~> 2.2' + spec.add_development_dependency 'rake', '~> 13.0' + spec.add_development_dependency 'rubocop', '~> 1.7' + spec.add_development_dependency 'rubocop-performance', '~> 1.9' end