diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..9f960493c --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,5 @@ +inherit_from: .rubocop_todo.yml + +inherit_gem: + rubocop-rails_config: + - config/rails.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 000000000..d16245ec4 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,357 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2018-08-27 17:05:32 +0200 using RuboCop version 0.58.2. +# 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: 13 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Layout/CaseIndentation: + Exclude: + - 'lib/puppet/report_sanitizer.rb' + - 'lib/report_transformer.rb' + - 'lib/tasks/summarize_reports.rake' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/ElseAlignment: + Exclude: + - 'lib/node_group_graph.rb' + +# Offense count: 39 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/controllers/node_class_memberships_controller.rb' + - 'app/controllers/node_group_class_memberships_controller.rb' + - 'app/controllers/nodes_controller.rb' + - 'app/controllers/pages_controller.rb' + - 'app/controllers/reports_controller.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundMethodBody: + Exclude: + - 'app/helpers/conflict_analyzer.rb' + - 'lib/has_parameters.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'app/helpers/conflict_html.rb' + - 'app/helpers/nodes_helper.rb' + - 'lib/puppet/report_sanitizer.rb' + - 'spec/support/describe_reports.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. +# SupportedStylesAlignWith: keyword, variable, start_of_line +Layout/EndAlignment: + Exclude: + - 'config/initializers/01_serialize_flash_as_hash.rb' + - 'lib/node_group_graph.rb' + - 'lib/report_transformer.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, rails +Layout/IndentationConsistency: + Exclude: + - 'spec/helpers/application_helper_spec.rb' + - 'spec/lib/puppet/report_sanitizer_spec.rb' + +# Offense count: 22 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Enabled: false + +# Offense count: 17 +# Cop supports --auto-correct. +Layout/LeadingCommentSpace: + Exclude: + - 'config/initializers/safe_yaml.rb' + - 'lib/node_group_graph.rb' + - 'lib/tasks/classesgroups.rake' + - 'spec/helpers/pages_helper_spec.rb' + - 'spec/helpers/status_helper_spec.rb' + - 'spec/models/report_spec.rb' + - 'spec/spec_helper.rb' + +# Offense count: 96 +# Cop supports --auto-correct. +Layout/SpaceAfterComma: + Enabled: false + +# Offense count: 19 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'app/helpers/application_helper.rb' + - 'app/helpers/paginate_scope_helper.rb' + - 'app/models/node.rb' + - 'app/models/status.rb' + - 'lib/data_generator.rb' + - 'lib/has_parameters.rb' + - 'lib/node_group_graph.rb' + - 'spec/support/report_support.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Layout/SpaceAroundKeyword: + Exclude: + - 'app/controllers/node_groups_controller.rb' + - 'app/controllers/nodes_controller.rb' + - 'app/helpers/conflict_html.rb' + +# Offense count: 77 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceAroundOperators: + Exclude: + - 'app/helpers/application_helper.rb' + - 'app/models/metric.rb' + - 'app/models/status.rb' + - 'lib/data_generator.rb' + - 'lib/node_group_graph.rb' + - 'lib/progress_bar.rb' + - 'spec/controllers/node_groups_controller_spec.rb' + - 'spec/controllers/nodes_controller_spec.rb' + - 'spec/factories.rb' + - 'spec/lib/puppet/report_sanitizer_spec.rb' + - 'spec/lib/report_transformer_spec.rb' + - 'spec/models/report_spec.rb' + - 'spec/models/resource_status_spec.rb' + +# Offense count: 55 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Enabled: false + +# Offense count: 266 +# Cop supports --auto-correct. +Layout/SpaceBeforeComma: + Exclude: + - 'app/helpers/application_helper.rb' + - 'spec/models/report_spec.rb' + +# Offense count: 217 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Enabled: false + +# Offense count: 199 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Enabled: false + +# Offense count: 34 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceInsideParens: + Exclude: + - 'app/helpers/conflict_html.rb' + - 'app/helpers/paginate_scope_helper.rb' + - 'app/helpers/reports_helper.rb' + - 'app/models/report.rb' + - 'config/initializers/check_migration_version.rb' + - 'lib/registry.rb' + - 'lib/tasks/install.rake' + - 'spec/controllers/nodes_controller_spec.rb' + - 'spec/helpers/application_helper_spec.rb' + - 'spec/models/report_spec.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingBlankLines: + Exclude: + - 'app/helpers/conflict_html.rb' + - 'config/initializers/check_migration_version.rb' + - 'config/initializers/time_formats.rb' + - 'lib/progress_bar.rb' + - 'lib/tasks/rake_helpers.rb' + - 'lib/tasks/schematize_reports.rake' + - 'lib/tasks/update_report_data.rake' + - 'spec/lib/settings_spec.rb' + - 'spec/models/resource_status_spec.rb' + - 'spec/shared_behaviors/controller_mixins.rb' + - 'spec/shared_behaviors/controller_search.rb' + - 'spec/support/should_matchers.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'app/helpers/conflict_analyzer.rb' + - 'config/initializers/check_migration_version.rb' + - 'lib/node_group_graph.rb' + - 'lib/tasks/install.rake' + - 'spec/shared_behaviors/restful_routing_behavior.rb' + +# Offense count: 25 +# Cop supports --auto-correct. +# Configuration parameters: MaxKeyValuePairs. +Performance/RedundantMerge: + Exclude: + - 'spec/controllers/node_groups_controller_spec.rb' + - 'spec/controllers/nodes_controller_spec.rb' + +# Offense count: 28 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'app/controllers/nodes_controller.rb' + - 'app/helpers/reports_helper.rb' + - 'app/models/node.rb' + - 'app/models/report.rb' + - 'config/initializers/check_migration_version.rb' + - 'lib/data_generator.rb' + - 'lib/find_from_form.rb' + - 'lib/node_group_graph.rb' + - 'lib/registry.rb' + - 'lib/report_transformer.rb' + - 'lib/tasks/classesgroups.rake' + - 'lib/tasks/import_reports.rake' + - 'lib/tasks/install.rake' + - 'lib/tasks/node.rake' + +# Offense count: 47 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: + Exclude: + - 'app/helpers/application_helper.rb' + - 'app/models/timeline_event.rb' + - 'spec/controllers/node_groups_controller_spec.rb' + - 'spec/controllers/nodes_controller_spec.rb' + - 'spec/helpers/application_helper_spec.rb' + - 'spec/views/node_groups/edit.html.haml_spec.rb' + - 'spec/views/nodes/edit.html.haml_spec.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'app/models/node.rb' + - 'lib/tasks/import_reports.rake' + - 'lib/tasks/install.rake' + +# Offense count: 10 +# Cop supports --auto-correct. +Style/DefWithParentheses: + Exclude: + - 'lib/puppet/report_sanitizer.rb' + +# Offense count: 194 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: when_needed, always, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 1199 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline +Style/MethodDefParentheses: + Exclude: + - 'lib/trimmer.rb' + +# Offense count: 20 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'app/controllers/files_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/models/node.rb' + - 'app/models/report.rb' + - 'app/models/status.rb' + - 'config/initializers/app_version_init.rb' + - 'lib/settings_reader.rb' + - 'lib/tasks/db_raw.rake' + - 'lib/tasks/install.rake' + - 'spec/support/from_response_body.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'app/controllers/node_groups_controller.rb' + - 'app/controllers/nodes_controller.rb' + - 'app/helpers/conflict_analyzer.rb' + - 'app/helpers/conflict_html.rb' + - 'lib/node_group_graph.rb' + - 'lib/progress_bar.rb' + +# Offense count: 2052 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. +# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +Style/TrivialAccessors: + Exclude: + - 'lib/progress_bar.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/UnneededPercentQ: + Exclude: + - 'spec/controllers/nodes_controller_spec.rb' + +# Offense count: 945 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 275 diff --git a/.travis.yml b/.travis.yml index 47c2bc35c..25e172e1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,3 +19,4 @@ before_script: - bundle exec rails db:migrate script: - bundle exec rails spec + - bundle exec rubocop diff --git a/Gemfile b/Gemfile index d2feb6252..021fdc632 100644 --- a/Gemfile +++ b/Gemfile @@ -43,6 +43,7 @@ group :development, :test do gem 'listen' gem 'simplecov' gem 'simplecov-console' + gem "rubocop-rails_config" end group :postgresql do diff --git a/Gemfile.lock b/Gemfile.lock index 8b9073e30..4fe69b672 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,6 +44,7 @@ GEM tzinfo (~> 1.1) ansi (1.5.0) arel (9.0.0) + ast (2.4.0) bindex (0.5.0) bootsnap (1.3.0) msgpack (~> 1.0) @@ -95,6 +96,7 @@ GEM has_scope (~> 0.6) railties (>= 4.2, <= 5.2) responders + jaro_winkler (1.5.1) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -128,7 +130,11 @@ GEM nio4r (2.3.0) nokogiri (1.8.2) mini_portile2 (~> 2.3.0) + parallel (1.12.1) + parser (2.5.1.2) + ast (~> 2.4.0) pg (1.0.0) + powerpack (0.1.2) rack (2.0.5) rack-test (1.0.0) rack (>= 1.0, < 3) @@ -160,6 +166,7 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) + rainbow (3.0.0) rake (12.3.1) rb-fsevent (0.10.3) rb-inotify (0.9.10) @@ -195,6 +202,18 @@ GEM rspec-mocks (~> 3.7.0) rspec-support (~> 3.7.0) rspec-support (3.7.1) + rubocop (0.58.2) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.5, != 2.5.1.1) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + rubocop-rails_config (0.2.3) + railties (>= 3.0) + rubocop (~> 0.56) + ruby-progressbar (1.10.0) ruby_dep (1.5.0) ruby_parser (3.11.0) sexp_processor (~> 4.9) @@ -246,6 +265,7 @@ GEM thread_safe (~> 0.1) uglifier (4.1.10) execjs (>= 0.3.0, < 3) + unicode-display_width (1.4.0) web-console (3.6.2) actionview (>= 5.0) activemodel (>= 5.0) @@ -286,6 +306,7 @@ DEPENDENCIES rspec-collection_matchers rspec-html-matchers rspec-rails + rubocop-rails_config safe_yaml sass-rails shoulda-matchers @@ -300,4 +321,4 @@ DEPENDENCIES will_paginate BUNDLED WITH - 1.16.0 + 1.16.2