From 29249b375168e06d9d8f23ea365f511cb63a00c6 Mon Sep 17 00:00:00 2001 From: Daniel Colson Date: Mon, 17 Sep 2018 20:40:28 -0400 Subject: [PATCH] Add RuboCop configuration This is similar to the work Christian Bruckmayer is doing over on factory_bot. I read that Hound doesn't support the `inherited_from` key, so I put all of the todos from the auto-generated `.rubocop_todo.yml` straight into the `.rubocop.yml`. fixup! Add RuboCop configuration --- .gitignore | 1 + .rubocop.yml | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++ Gemfile | 2 + Gemfile.lock | 16 +++++ 4 files changed, 213 insertions(+) create mode 100644 .rubocop.yml diff --git a/.gitignore b/.gitignore index c713fd4..d0fad55 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ pkg rdoc test.db tmp +.rubocop-https* diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..acea765 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,194 @@ +inherit_from: + - https://raw.githubusercontent.com/thoughtbot/guides/master/style/ruby/.rubocop.yml + +AllCops: + Exclude: + - "tmp/**/*" + +# TODO: +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2018-09-17 20:19:38 -0400 using RuboCop version 0.54.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 18 +# Cop supports --auto-correct. +# Configuration parameters: Include, TreatCommentsAsGroupSeparators. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'Gemfile' + - 'gemfiles/rails4.2.gemfile' + - 'gemfiles/rails5.0.gemfile' + - 'gemfiles/rails5.1.gemfile' + - 'gemfiles/rails5.2.gemfile' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include, TreatCommentsAsGroupSeparators. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'factory_bot_rails.gemspec' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent +Layout/IndentHeredoc: + Exclude: + - 'features/step_definitions/rails_steps.rb' + - 'lib/generators/factory_bot/model/model_generator.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Exclude: + - 'lib/generators/factory_bot/model/model_generator.rb' + +# Offense count: 7 +Lint/AmbiguousRegexpLiteral: + Exclude: + - 'features/step_definitions/appraisal.rb' + - 'features/step_definitions/rails_steps.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'Rakefile' + - 'features/support/env.rb' + +# Offense count: 2 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 40 + +# Offense count: 2 +# Configuration parameters: Blacklist. +# Blacklist: END, (?-mix:EO[A-Z]{1}) +Naming/HeredocDelimiterNaming: + Exclude: + - 'features/step_definitions/rails_steps.rb' + +# Offense count: 1 +Naming/MemoizedInstanceVariableName: + Exclude: + - 'lib/generators/factory_bot.rb' + +# Offense count: 9 +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'lib/factory_bot_rails.rb' + - 'lib/factory_bot_rails/definition_file_paths.rb' + - 'lib/factory_bot_rails/generator.rb' + - 'lib/factory_bot_rails/generators/non_rspec_generator.rb' + - 'lib/factory_bot_rails/generators/null_generator.rb' + - 'lib/factory_bot_rails/generators/rspec_generator.rb' + - 'lib/factory_bot_rails/railtie.rb' + - 'lib/factory_bot_rails/reloader.rb' + - 'lib/generators/factory_bot/model/model_generator.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'lib/factory_bot_rails/generators/null_generator.rb' + +# Offense count: 29 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Exclude: + - 'Rakefile' + - 'gemfiles/rails4.2.gemfile' + - 'gemfiles/rails5.0.gemfile' + - 'gemfiles/rails5.1.gemfile' + - 'gemfiles/rails5.2.gemfile' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/MultilineIfModifier: + Exclude: + - 'features/support/env.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'factory_bot_rails.gemspec' + - 'features/step_definitions/rails_steps.rb' + +# Offense count: 84 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + EnforcedStyle: "double_quotes" + Exclude: + - 'Appraisals' + - 'Gemfile' + - 'Rakefile' + - 'factory_bot_rails.gemspec' + - 'features/step_definitions/rails_steps.rb' + - 'features/support/env.rb' + - 'lib/factory_bot_rails.rb' + - 'lib/factory_bot_rails/generator.rb' + - 'lib/factory_bot_rails/generators/rspec_generator.rb' + - 'lib/generators/factory_bot.rb' + - 'lib/generators/factory_bot/model/model_generator.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiteralsInInterpolation: + Exclude: + - 'lib/generators/factory_bot/model/model_generator.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArguments: + Exclude: + - 'spec/factory_bot_rails/definition_file_paths_spec.rb' + - 'lib/generators/factory_bot/model/model_generator.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Style/UnneededPercentQ: + Exclude: + - 'factory_bot_rails.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 3 + +# Offense count: 11 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 133 + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'Rakefile' + diff --git a/Gemfile b/Gemfile index edbe1b8..5c66869 100644 --- a/Gemfile +++ b/Gemfile @@ -18,3 +18,5 @@ gem 'therubyrhino', platforms: :jruby gem 'jruby-openssl', platforms: :jruby gem 'sqlite3', platforms: :ruby + +gem "rubocop", "0.54", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 0efedf4..e596245 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,6 +49,7 @@ GEM ffi (~> 1.9.10) rspec-expectations (>= 2.99) thor (~> 0.19) + ast (2.4.0) builder (3.2.3) childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) @@ -99,7 +100,11 @@ GEM nokogiri (1.8.4) mini_portile2 (~> 2.3.0) nokogiri (1.8.4-java) + parallel (1.12.1) + parser (2.5.1.2) + ast (~> 2.4.0) power_assert (1.1.3) + powerpack (0.1.2) rack (2.0.5) rack-test (1.1.0) rack (>= 1.0, < 3) @@ -114,6 +119,7 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) + rainbow (3.0.0) rake (12.3.1) rspec-core (3.7.1) rspec-support (~> 3.7.0) @@ -132,6 +138,14 @@ GEM rspec-mocks (~> 3.7.0) rspec-support (~> 3.7.0) rspec-support (3.7.1) + rubocop (0.54.0) + parallel (~> 1.10) + parser (>= 2.5) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.10.0) sqlite3 (1.3.13) test-unit (3.2.8) power_assert @@ -145,6 +159,7 @@ GEM thread_safe (~> 0.1) uglifier (4.1.16) execjs (>= 0.3.0, < 3) + unicode-display_width (1.4.0) PLATFORMS java @@ -162,6 +177,7 @@ DEPENDENCIES jruby-openssl rake rspec-rails + rubocop (= 0.54) sqlite3 test-unit therubyrhino