From 95c49c00a98d118de27cbf4b76a0814c966622cc Mon Sep 17 00:00:00 2001 From: Garett Arrowood Date: Sat, 20 Jan 2018 08:23:20 -0500 Subject: [PATCH 1/6] Generate a rubocop_todo.yml --- .rubocop.yml | 1 + .rubocop_todo.yml | 745 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 746 insertions(+) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 29d6341570..4d5c39fd5e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,5 @@ inherit_from: + - .rubocop_todo.yml - .rubocop_rspec_base.yml AllCops: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000000..de75087bbc --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,745 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2018-01-20 08:21:01 -0500 using RuboCop version 0.52.1. +# 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: 2 +# Configuration parameters: Include. +# Include: **/Gemfile, **/gems.rb +Bundler/DuplicatedGem: + Exclude: + - 'Gemfile' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include, TreatCommentsAsGroupSeparators. +# Include: **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'Gemfile' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Include, TreatCommentsAsGroupSeparators. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'rspec-core.gemspec' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'rspec-core.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/AlignArray: + Exclude: + - 'spec/rspec/core/filter_manager_spec.rb' + - 'spec/rspec/core/resources/formatter_specs.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/AlignHash: + Exclude: + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/formatters/exception_presenter_spec.rb' + +# Offense count: 23 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_parameter, with_fixed_indentation +Layout/AlignParameters: + Exclude: + - 'benchmarks/threadsafe_let_block.rb' + - 'features/step_definitions/additional_cli_steps.rb' + - 'spec/rspec/core/backtrace_formatter_spec.rb' + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/formatters/documentation_formatter_spec.rb' + - 'spec/rspec/core/formatters/exception_presenter_spec.rb' + - 'spec/rspec/core/formatters_spec.rb' + - 'spec/rspec/core/rake_task_spec.rb' + - 'spec/rspec/core/reporter_spec.rb' + - 'spec/rspec/core_spec.rb' + - 'spec/support/formatter_support.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Layout/CaseIndentation: + Exclude: + - 'spec/support/matchers.rb' + +# Offense count: 32 +# Cop supports --auto-correct. +Layout/CommentIndentation: + Exclude: + - 'benchmarks/check_inclusion.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'spec/integration/persistence_failures_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/example_spec.rb' + - 'spec/rspec/core/formatters/console_codes_spec.rb' + - 'spec/rspec/core/formatters/helpers_spec.rb' + +# Offense count: 30 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundArguments: + Exclude: + - 'spec/integration/failed_line_detection_spec.rb' + - 'spec/integration/filtering_spec.rb' + - 'spec/integration/order_spec.rb' + - 'spec/integration/spec_file_load_errors_spec.rb' + - 'spec/integration/suite_hooks_errors_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'spec/rspec/core/world_spec.rb' + - 'spec/support/formatter_support.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/IndentHash: + EnforcedStyle: consistent + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, rails +Layout/IndentationConsistency: + Exclude: + - 'spec/rspec/core/metadata_filter_spec.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Exclude: + - 'benchmarks/respond_to_v_defined.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core_spec.rb' + - 'spec/support/formatter_support.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/LeadingCommentSpace: + Exclude: + - 'spec/rspec/core/formatters/progress_formatter_spec.rb' + - 'spec/rspec/core/metadata_spec.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Layout/MultilineBlockLayout: + Exclude: + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/metadata_filter_spec.rb' + +# Offense count: 49 +# Cop supports --auto-correct. +Layout/SpaceAfterComma: + Exclude: + - 'spec/rspec/core/backtrace_formatter_spec.rb' + - 'spec/rspec/core/configuration_options_spec.rb' + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/drb_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/filter_manager_spec.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + - 'spec/rspec/core/metadata_filter_spec.rb' + - 'spec/rspec/core/option_parser_spec.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'benchmarks/singleton_example_groups/helper.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/example_status_persister_spec.rb' + - 'spec/support/formatter_support.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/SpaceAroundKeyword: + Exclude: + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + +# Offense count: 22 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + EnforcedStyleForEmptyBraces: no_space + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceBeforeFirstArg: + Exclude: + - 'spec/rspec/core/drb_spec.rb' + +# Offense count: 58 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'spec/rspec/core/bisect/runner_spec.rb' + - 'spec/rspec/core/configuration_options_spec.rb' + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/example_status_persister_spec.rb' + - 'spec/rspec/core/formatters/exception_presenter_spec.rb' + - 'spec/rspec/core/formatters/snippet_extractor_spec.rb' + - 'spec/rspec/core/metadata_spec.rb' + - 'spec/rspec/core/notifications_spec.rb' + - 'spec/rspec/core/shared_example_group_spec.rb' + - 'spec/rspec/core/suite_hooks_spec.rb' + +# Offense count: 315 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Enabled: false + +# Offense count: 81 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/drb_spec.rb' + - 'spec/rspec/core/filter_manager_spec.rb' + - 'spec/rspec/core/hooks_spec.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + - 'spec/rspec/core/metadata_filter_spec.rb' + - 'spec/rspec/core/runner_spec.rb' + - 'spec/rspec/core/shared_example_group_spec.rb' + +# Offense count: 41 +# Cop supports --auto-correct. +Layout/SpaceInsideParens: + Exclude: + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/drb_spec.rb' + - 'spec/rspec/core/example_status_persister_spec.rb' + - 'spec/rspec/core/formatters/documentation_formatter_spec.rb' + - 'spec/rspec/core/formatters/json_formatter_spec.rb' + - 'spec/rspec/core/formatters_spec.rb' + - 'spec/rspec/core/metadata_spec.rb' + - 'spec/rspec/core/profiler_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingBlankLines: + Exclude: + - 'benchmarks/eager_vs_lazy_metadata/define_examples.rb' + - 'features/support/send_sigint_during_bisect.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + - 'spec/rspec/core/rspec_matchers_spec.rb' + - 'spec/rspec/core_spec.rb' + +# Offense count: 14 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'benchmarks/threadsafe_let_block.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/example_spec.rb' + - 'spec/rspec/core/formatters/exception_presenter_spec.rb' + - 'spec/rspec/core/formatters/syntax_highlighter_spec.rb' + - 'spec/rspec/core/formatters_spec.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + - 'spec/rspec/core/option_parser_spec.rb' + - 'spec/rspec/core/world_spec.rb' + +# Offense count: 1 +Lint/AmbiguousOperator: + Exclude: + - 'benchmarks/threadsafe_let_block.rb' + +# Offense count: 16 +Lint/AmbiguousRegexpLiteral: + Exclude: + - 'features/step_definitions/additional_cli_steps.rb' + +# Offense count: 2 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'benchmarks/index_v_take_while.rb' + - 'spec/rspec/core/metadata_spec.rb' + +# Offense count: 2 +Lint/BooleanSymbol: + Exclude: + - 'spec/rspec/core/example_group_spec.rb' + +# Offense count: 2 +Lint/HandleExceptions: + Exclude: + - 'lib/rspec/core/example.rb' + - 'lib/rspec/core/mocking_adapters/mocha.rb' + - 'lib/rspec/core/runner.rb' + - 'lib/rspec/core/test_unit_assertions_adapter.rb' + - 'script/rspec_with_simplecov' + - 'spec/rspec/core/example_spec.rb' + +# Offense count: 2 +Lint/InterpolationCheck: + Exclude: + - 'spec/rspec/core/bisect/runner_spec.rb' + - 'spec/rspec/core/formatters/exception_presenter_spec.rb' + +# Offense count: 1 +Lint/ShadowingOuterLocalVariable: + Exclude: + - 'benchmarks/hash_functions.rb' + +# Offense count: 22 +# Cop supports --auto-correct. +Lint/UnneededSplatExpansion: + Exclude: + - 'spec/rspec/core/configuration_options_spec.rb' + - 'spec/rspec/core/drb_spec.rb' + +# Offense count: 24 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'features/support/env.rb' + - 'features/support/jruby.rb' + - 'features/support/rubinius.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/formatters/exception_presenter_spec.rb' + - 'spec/rspec/core/formatters/json_formatter_spec.rb' + - 'spec/rspec/core/invocations_spec.rb' + - 'spec/rspec/core/metadata_filter_spec.rb' + - 'spec/rspec/core/metadata_spec.rb' + - 'spec/rspec/core/notifications_spec.rb' + - 'spec/rspec/core/rake_task_spec.rb' + - 'spec/rspec/core/reporter_spec.rb' + - 'spec/support/formatter_support.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'benchmarks/capture_block_vs_yield.rb' + +# Offense count: 1 +Lint/UselessAssignment: + Exclude: + - 'benchmarks/hash_functions.rb' + +# Offense count: 2 +Lint/UselessComparison: + Exclude: + - 'spec/rspec/core/example_spec.rb' + +# Offense count: 2 +Lint/Void: + Exclude: + - 'spec/rspec/core/example_group_spec.rb' + +# Offense count: 1 +Metrics/AbcSize: + Max: 283 + +# Offense count: 32 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 2222 + +# Offense count: 68 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 172 + +# Offense count: 1 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 134 + +# Offense count: 30 +# Configuration parameters: CountComments. +Metrics/ModuleLength: + Max: 2200 + +# Offense count: 1 +# Configuration parameters: CountKeywordArgs. +Metrics/ParameterLists: + Max: 6 + +# Offense count: 3 +Naming/AsciiIdentifiers: + Exclude: + - 'spec/rspec/core/resources/utf8_encoded.rb' + +# Offense count: 2 +# Configuration parameters: . +# SupportedStyles: snake_case, camelCase +Naming/MethodName: + EnforcedStyle: snake_case + +# Offense count: 1 +# Configuration parameters: . +# SupportedStyles: snake_case, camelCase +Naming/VariableName: + EnforcedStyle: snake_case + +# Offense count: 1 +Performance/Caller: + Exclude: + - 'lib/rspec/core/example_group.rb' + - 'spec/support/formatter_support.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IncludeActiveSupportAliases. +Performance/DoubleStartEndWith: + Exclude: + - 'features/step_definitions/additional_cli_steps.rb' + +# Offense count: 1 +Performance/FixedSize: + Exclude: + - 'benchmarks/allocations/helper.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Performance/RedundantBlockCall: + Exclude: + - 'lib/rspec/core/rake_task.rb' + - 'benchmarks/call_v_yield.rb' + - 'benchmarks/capture_block_vs_yield.rb' + - 'benchmarks/to_proc_v_not_to_proc.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect. +Performance/TimesMap: + Exclude: + - 'benchmarks/check_inclusion.rb' + - 'benchmarks/singleton_example_groups/helper.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/ordering_spec.rb' + +# Offense count: 1 +Security/Eval: + Exclude: + - 'Gemfile' + +# Offense count: 1 +# Configuration parameters: AllowedChars. +Style/AsciiComments: + Exclude: + - 'spec/rspec/core/formatters/exception_presenter_spec.rb' + +# Offense count: 46 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: + Exclude: + - 'spec/rspec/core/bisect/coordinator_spec.rb' + - 'spec/rspec/core/bisect/example_minimizer_spec.rb' + - 'spec/rspec/core/bisect/runner_spec.rb' + - 'spec/rspec/core/configuration/only_failures_support_spec.rb' + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/drb_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/example_spec.rb' + - 'spec/rspec/core/filter_manager_spec.rb' + - 'spec/rspec/core/filterable_item_repository_spec.rb' + - 'spec/rspec/core/hooks_spec.rb' + - 'spec/rspec/core/metadata_filter_spec.rb' + +# Offense count: 39 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Enabled: false + +# Offense count: 1 +Style/ClassVars: + Exclude: + - 'benchmarks/singleton_example_groups/helper.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'spec/rspec/core/drb_spec.rb' + - 'spec/rspec/core/formatters/base_text_formatter_spec.rb' + - 'spec/rspec/core/shared_example_group_spec.rb' + - 'spec/rspec/core_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/Dir: + Exclude: + - 'spec/support/spec_files.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +Style/Encoding: + Exclude: + - 'lib/rspec/core/formatters/exception_presenter.rb' + - 'rspec-core.gemspec' + - 'spec/rspec/core/example_group_constants_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/formatters/base_text_formatter_spec.rb' + - 'spec/rspec/core/formatters/exception_presenter_spec.rb' + - 'spec/rspec/core/formatters/html_formatter_spec.rb' + - 'spec/rspec/core/resources/utf8_encoded.rb' + +# Offense count: 1 +Style/EvalWithLocation: + Exclude: + - 'benchmarks/call_v_yield.rb' + +# Offense count: 20 +# Configuration parameters: AllowedVariables. +Style/GlobalVars: + Exclude: + - 'benchmarks/map_then_flatten_vs_flat_map_benchmarks.rb' + - 'benchmarks/several_regexps_v_one_big_one.rb' + - 'benchmarks/shuffle_vs_sort_by_for_random_ordering.rb' + - 'benchmarks/to_proc_v_not_to_proc.rb' + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/formatters/base_text_formatter_spec.rb' + - 'spec/rspec/core/metadata_spec.rb' + - 'spec/spec_helper.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Exclude: + - 'benchmarks/allocations/helper.rb' + - 'benchmarks/allocations/running_1000_groups_1_example.rb' + - 'benchmarks/allocations/running_1_group_1000_examples.rb' + - 'benchmarks/singleton_example_groups/helper.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +Style/LineEndConcatenation: + Exclude: + - 'spec/rspec/core/formatters/base_text_formatter_spec.rb' + - 'spec/rspec/core/option_parser_spec.rb' + +# Offense count: 33 +# Cop supports --auto-correct. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'spec/rspec/core/configuration_options_spec.rb' + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/formatters/base_text_formatter_spec.rb' + - 'spec/rspec/core/metadata_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline +Style/MethodDefParentheses: + Exclude: + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/formatters/json_formatter_spec.rb' + - 'spec/rspec/core/formatters/profile_formatter_spec.rb' + - 'spec/support/formatter_support.rb' + +# Offense count: 1 +Style/MultilineBlockChain: + Exclude: + - 'spec/rspec/core/invocations_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedOctalStyle. +# SupportedOctalStyles: zero_with_o, zero_only +Style/NumericLiteralPrefix: + Exclude: + - 'spec/integration/persistence_failures_spec.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: Strict. +Style/NumericLiterals: + MinDigits: 11 + +# Offense count: 35 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'benchmarks/filter_object.rb' + - 'benchmarks/several_regexps_v_one_big_one.rb' + - 'features/step_definitions/additional_cli_steps.rb' + - 'spec/rspec/core/drb_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + - 'spec/rspec/core/rake_task_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/PerlBackrefs: + Exclude: + - 'features/step_definitions/additional_cli_steps.rb' + - 'spec/spec_helper.rb' + - 'spec/support/formatter_support.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + Exclude: + - 'lib/rspec/core/configuration.rb' + - 'lib/rspec/core/hooks.rb' + - 'lib/rspec/core/option_parser.rb' + - 'lib/rspec/core/pending.rb' + - 'spec/rspec/core/formatters/base_text_formatter_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RandomWithOffset: + Exclude: + - 'spec/integration/spec_file_load_errors_spec.rb' + - 'spec/integration/suite_hooks_errors_spec.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +Style/RedundantSelf: + Exclude: + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RescueModifier: + Exclude: + - 'spec/rspec/core/memoized_helpers_spec.rb' + - 'spec/rspec/core/reporter_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/SelfAssignment: + Exclude: + - 'spec/rspec/core/hooks_spec.rb' + +# Offense count: 59 +# Cop supports --auto-correct. +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'benchmarks/keys_each_vs_each_key.rb' + - 'benchmarks/threadsafe_let_block.rb' + - 'spec/rspec/core/aggregate_failures_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/example_spec.rb' + - 'spec/rspec/core/filter_manager_spec.rb' + - 'spec/rspec/core/formatters/json_formatter_spec.rb' + - 'spec/rspec/core/hooks_filtering_spec.rb' + - 'spec/rspec/core/hooks_spec.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +# Configuration parameters: AllowIfMethodIsEmpty. +Style/SingleLineMethods: + Exclude: + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + - 'spec/rspec/core/shared_example_group_spec.rb' + - 'spec/support/fake_libs/rspec/expectations.rb' + - 'spec/support/fake_libs/rspec/mocks.rb' + +# Offense count: 1 +# 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: + - 'benchmarks/define_method_v_attr_reader_v_def.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/UnneededCapitalW: + Exclude: + - 'spec/integration/bisect_spec.rb' + - 'spec/rspec/core/bisect/runner_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/UnneededInterpolation: + Exclude: + - 'spec/rspec/core/formatters/base_text_formatter_spec.rb' + +# Offense count: 24 +# Cop supports --auto-correct. +Style/UnneededPercentQ: + Exclude: + - 'benchmarks/filter_object.rb' + - 'features/step_definitions/additional_cli_steps.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/support/spec_files.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + Exclude: + - 'spec/integration/order_spec.rb' + - 'spec/rspec/core/configuration_options_spec.rb' + - 'spec/rspec/core/configuration_spec.rb' + - 'spec/rspec/core/example_group_spec.rb' + - 'spec/rspec/core/formatters/snippet_extractor_spec.rb' + - 'spec/rspec/core/memoized_helpers_spec.rb' + - 'spec/rspec/core/shared_context_spec.rb' From e597c4c3cc201df9d747c34f10de0175cd725491 Mon Sep 17 00:00:00 2001 From: Garett Arrowood Date: Sat, 20 Jan 2018 09:30:16 -0500 Subject: [PATCH 2/6] Make necessary changes for green CI --- .rubocop.yml | 4 ++++ lib/rspec/core/formatters/html_printer.rb | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4d5c39fd5e..b782e729f8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -109,3 +109,7 @@ Performance/Caller: Metrics/BlockLength: Max: 193 + +Layout/SpaceBeforeBlockBraces: + EnforcedStyle: space + EnforcedStyleForEmptyBraces: space diff --git a/lib/rspec/core/formatters/html_printer.rb b/lib/rspec/core/formatters/html_printer.rb index 16f96df659..378e742e78 100644 --- a/lib/rspec/core/formatters/html_printer.rb +++ b/lib/rspec/core/formatters/html_printer.rb @@ -33,10 +33,8 @@ def print_example_passed(description, run_time) "#{formatted_run_time}s" end - # rubocop:disable Metrics/ParameterLists def print_example_failed(pending_fixed, description, run_time, failure_id, exception, extra_content) - # rubocop:enable Metrics/ParameterLists formatted_run_time = "%.5f" % run_time @output.puts "
" From b728de5581b55af1d675e044ca5bee1eaa25d6a0 Mon Sep 17 00:00:00 2001 From: Garett Arrowood Date: Sat, 20 Jan 2018 10:01:25 -0500 Subject: [PATCH 3/6] Inline whitelist ParameterLists offense & regenerate todo --- .rubocop_todo.yml | 7 +------ lib/rspec/core/formatters/html_printer.rb | 2 ++ spec/support/formatter_support.rb | 2 ++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index de75087bbc..6a00cedc78 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-01-20 08:21:01 -0500 using RuboCop version 0.52.1. +# on 2018-01-20 10:08:35 -0500 using RuboCop version 0.52.1. # 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 @@ -399,11 +399,6 @@ Metrics/MethodLength: Metrics/ModuleLength: Max: 2200 -# Offense count: 1 -# Configuration parameters: CountKeywordArgs. -Metrics/ParameterLists: - Max: 6 - # Offense count: 3 Naming/AsciiIdentifiers: Exclude: diff --git a/lib/rspec/core/formatters/html_printer.rb b/lib/rspec/core/formatters/html_printer.rb index 378e742e78..69e089eb68 100644 --- a/lib/rspec/core/formatters/html_printer.rb +++ b/lib/rspec/core/formatters/html_printer.rb @@ -33,6 +33,7 @@ def print_example_passed(description, run_time) "#{formatted_run_time}s
" end + # rubocop:disable Metrics/ParameterLists def print_example_failed(pending_fixed, description, run_time, failure_id, exception, extra_content) formatted_run_time = "%.5f" % run_time @@ -49,6 +50,7 @@ def print_example_failed(pending_fixed, description, run_time, failure_id, @output.puts " " @output.puts " " end + # rubocop:enable Metrics/ParameterLists def print_example_pending(description, pending_message) @output.puts "
" \ diff --git a/spec/support/formatter_support.rb b/spec/support/formatter_support.rb index d9bc01a3ef..8946859350 100644 --- a/spec/support/formatter_support.rb +++ b/spec/support/formatter_support.rb @@ -352,9 +352,11 @@ def failed_examples_notification ::RSpec::Core::Notifications::ExamplesNotification.new reporter end + # rubocop:disable Metrics/ParameterLists def summary_notification(duration, examples, failed, pending, time, errors = 0) ::RSpec::Core::Notifications::SummaryNotification.new duration, examples, failed, pending, time, errors end + # rubocop:enable Metrics/ParameterLists def profile_notification(duration, examples, number) ::RSpec::Core::Notifications::ProfileNotification.new duration, examples, number, reporter.instance_variable_get('@profiler').example_groups From a0657ddae32d7d1736e3059e22ca061324074ad5 Mon Sep 17 00:00:00 2001 From: Garett Arrowood Date: Sun, 21 Jan 2018 07:15:01 -0500 Subject: [PATCH 4/6] New rubocop config & todo before cleanup --- .rubocop.yml | 36 ++++++++++++++++++++++++++---------- .rubocop_todo.yml | 25 +++---------------------- BUILD_DETAIL.md | 4 ++-- DEVELOPMENT.md | 2 +- Rakefile | 4 ++-- script/functions.sh | 4 ++-- 6 files changed, 36 insertions(+), 39 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b782e729f8..8ef167deb2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,10 +7,6 @@ AllCops: # This code was taken from the backports gem. We don't want to mess with it. - lib/rspec/core/backport_random.rb -# This should go down over time. -Metrics/ClassLength: - Max: 330 - Encoding: Exclude: - lib/rspec/core/formatters/exception_presenter.rb @@ -18,21 +14,44 @@ Encoding: # This should go down over time. Metrics/AbcSize: Max: 40 + Exclude: + - 'spec/**/*' + +Metrics/BlockLength: + Max: 193 + Exclude: + - 'spec/**/*' + +# This should go down over time. +Metrics/ClassLength: + Max: 330 + +# This should go down over time. +Metrics/CyclomaticComplexity: + Max: 12 + Exclude: + - 'spec/**/*' # This should go down over time. Metrics/LineLength: Max: 130 + Exclude: + - 'spec/**/*' # This should go down over time. Metrics/MethodLength: Max: 37 + Exclude: + - 'spec/**/*' -# This should go down over time. -Metrics/CyclomaticComplexity: - Max: 12 +Metrics/ModuleLength: + Exclude: + - 'spec/**/*' Metrics/PerceivedComplexity: Max: 15 + Exclude: + - 'spec/**/*' Lint/HandleExceptions: Exclude: @@ -107,9 +126,6 @@ Performance/Caller: # particular case to see if it's worth introducing version branching. - 'lib/rspec/core/example_group.rb' -Metrics/BlockLength: - Max: 193 - Layout/SpaceBeforeBlockBraces: EnforcedStyle: space EnforcedStyleForEmptyBraces: space diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6a00cedc78..bc2fe65eb8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-01-20 10:08:35 -0500 using RuboCop version 0.52.1. +# on 2018-01-21 07:11:04 -0500 using RuboCop version 0.52.1. # 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 @@ -374,30 +374,11 @@ Lint/Void: Exclude: - 'spec/rspec/core/example_group_spec.rb' -# Offense count: 1 -Metrics/AbcSize: - Max: 283 - -# Offense count: 32 -# Configuration parameters: CountComments, ExcludedMethods. -Metrics/BlockLength: - Max: 2222 - -# Offense count: 68 +# Offense count: 3 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: - Max: 172 - -# Offense count: 1 -# Configuration parameters: CountComments. -Metrics/MethodLength: - Max: 134 - -# Offense count: 30 -# Configuration parameters: CountComments. -Metrics/ModuleLength: - Max: 2200 + Max: 158 # Offense count: 3 Naming/AsciiIdentifiers: diff --git a/BUILD_DETAIL.md b/BUILD_DETAIL.md index 61e2da818a..67246e0504 100644 --- a/BUILD_DETAIL.md +++ b/BUILD_DETAIL.md @@ -103,11 +103,11 @@ We use [Rubocop](https://github.com/bbatsov/rubocop) to enforce style convention that the code has stylistic consistency throughout. Run with: ``` -$ bundle exec rubocop lib +$ bundle exec rubocop # or, if you installed your bundle with `--standalone --binstubs`: -$ bin/rubocop lib +$ bin/rubocop ``` Our Rubocop configuration is a work-in-progress, so if you get a failure diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 2979960bc4..d8415dd8fc 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -108,7 +108,7 @@ Here's a short, non-exhaustive checklist of things we typically ask contributors - [ ] New behavior is covered by tests and all tests are passing. - [ ] No Ruby warnings are issued by your changes. - [ ] Documentation reflects changes and renders as intended. -- [ ] Rubocop passes (e.g. `bundle exec rubocop lib`). +- [ ] Rubocop passes (e.g. `bundle exec rubocop`). - [ ] Commits are squashed into a reasonable number of logical changesets that tell an easy-to-follow story. - [ ] No changelog entry is necessary (we'll add it as part of the merge process!) diff --git a/Rakefile b/Rakefile index 550f874261..e6f664d210 100644 --- a/Rakefile +++ b/Rakefile @@ -23,9 +23,9 @@ namespace :spec do end end -desc 'Run RuboCop on the lib directory' +desc 'Run RuboCop' task :rubocop do - sh 'bundle exec rubocop lib' + sh 'bundle exec rubocop' end desc "delete generated files" diff --git a/script/functions.sh b/script/functions.sh index cd53f75224..af84e10165 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -179,8 +179,8 @@ function check_documentation_coverage { } function check_style_and_lint { - echo "bin/rubocop lib" - eval "(unset RUBYOPT; exec bin/rubocop lib)" + echo "bin/rubocop" + eval "(unset RUBYOPT; exec bin/rubocop)" } function run_all_spec_suites { From 51cf10815cb5e1c4b4f857d183a4d5b9aaf74e75 Mon Sep 17 00:00:00 2001 From: Garett Arrowood Date: Sun, 21 Jan 2018 07:50:20 -0500 Subject: [PATCH 5/6] Cleanup offenses --- .rubocop.yml | 7 +- .rubocop_todo.yml | 79 ++----------------- benchmarks/call_v_yield.rb | 2 +- benchmarks/capture_block_vs_yield.rb | 2 + benchmarks/singleton_example_groups/helper.rb | 6 +- benchmarks/to_proc_v_not_to_proc.rb | 2 +- .../step_definitions/additional_cli_steps.rb | 2 +- rspec-core.gemspec | 2 +- script/rspec_with_simplecov | 2 +- spec/rspec/core/drb_spec.rb | 2 +- spec/rspec/core/example_group_spec.rb | 8 +- spec/rspec/core/example_spec.rb | 2 +- .../formatters/base_text_formatter_spec.rb | 2 +- spec/rspec/core/memoized_helpers_spec.rb | 2 +- spec/rspec/core/resources/utf8_encoded.rb | 4 +- spec/support/formatter_support.rb | 2 +- 16 files changed, 32 insertions(+), 94 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8ef167deb2..e550072e9b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,10 +7,6 @@ AllCops: # This code was taken from the backports gem. We don't want to mess with it. - lib/rspec/core/backport_random.rb -Encoding: - Exclude: - - lib/rspec/core/formatters/exception_presenter.rb - # This should go down over time. Metrics/AbcSize: Max: 40 @@ -66,6 +62,9 @@ Lint/LiteralInInterpolation: Lint/NonLocalExitFromIterator: Enabled: false +Style/Encoding: + Enabled: false + # We don't care about single vs double qoutes. Style/StringLiteralsInInterpolation: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bc2fe65eb8..e4940980b0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-01-21 07:11:04 -0500 using RuboCop version 0.52.1. +# on 2018-01-21 07:40:12 -0500 using RuboCop version 0.52.1. # 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 @@ -187,13 +187,16 @@ Layout/SpaceAroundKeyword: - 'spec/rspec/core/configuration_spec.rb' - 'spec/rspec/core/memoized_helpers_spec.rb' -# Offense count: 22 +# Offense count: 16 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceBeforeBlockBraces: - EnforcedStyleForEmptyBraces: no_space + Exclude: + - 'spec/rspec/core/formatters/documentation_formatter_spec.rb' + - 'spec/rspec/core/metadata_filter_spec.rb' + - 'spec/rspec/core/project_initializer_spec.rb' # Offense count: 3 # Cop supports --auto-correct. @@ -305,16 +308,6 @@ Lint/BooleanSymbol: Exclude: - 'spec/rspec/core/example_group_spec.rb' -# Offense count: 2 -Lint/HandleExceptions: - Exclude: - - 'lib/rspec/core/example.rb' - - 'lib/rspec/core/mocking_adapters/mocha.rb' - - 'lib/rspec/core/runner.rb' - - 'lib/rspec/core/test_unit_assertions_adapter.rb' - - 'script/rspec_with_simplecov' - - 'spec/rspec/core/example_spec.rb' - # Offense count: 2 Lint/InterpolationCheck: Exclude: @@ -374,35 +367,11 @@ Lint/Void: Exclude: - 'spec/rspec/core/example_group_spec.rb' -# Offense count: 3 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 158 - # Offense count: 3 Naming/AsciiIdentifiers: Exclude: - 'spec/rspec/core/resources/utf8_encoded.rb' -# Offense count: 2 -# Configuration parameters: . -# SupportedStyles: snake_case, camelCase -Naming/MethodName: - EnforcedStyle: snake_case - -# Offense count: 1 -# Configuration parameters: . -# SupportedStyles: snake_case, camelCase -Naming/VariableName: - EnforcedStyle: snake_case - -# Offense count: 1 -Performance/Caller: - Exclude: - - 'lib/rspec/core/example_group.rb' - - 'spec/support/formatter_support.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: IncludeActiveSupportAliases. @@ -415,15 +384,6 @@ Performance/FixedSize: Exclude: - 'benchmarks/allocations/helper.rb' -# Offense count: 4 -# Cop supports --auto-correct. -Performance/RedundantBlockCall: - Exclude: - - 'lib/rspec/core/rake_task.rb' - - 'benchmarks/call_v_yield.rb' - - 'benchmarks/capture_block_vs_yield.rb' - - 'benchmarks/to_proc_v_not_to_proc.rb' - # Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect. @@ -491,19 +451,6 @@ Style/Dir: Exclude: - 'spec/support/spec_files.rb' -# Offense count: 7 -# Cop supports --auto-correct. -Style/Encoding: - Exclude: - - 'lib/rspec/core/formatters/exception_presenter.rb' - - 'rspec-core.gemspec' - - 'spec/rspec/core/example_group_constants_spec.rb' - - 'spec/rspec/core/example_group_spec.rb' - - 'spec/rspec/core/formatters/base_text_formatter_spec.rb' - - 'spec/rspec/core/formatters/exception_presenter_spec.rb' - - 'spec/rspec/core/formatters/html_formatter_spec.rb' - - 'spec/rspec/core/resources/utf8_encoded.rb' - # Offense count: 1 Style/EvalWithLocation: Exclude: @@ -608,18 +555,6 @@ Style/PerlBackrefs: - 'spec/spec_helper.rb' - 'spec/support/formatter_support.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: compact, exploded -Style/RaiseArgs: - Exclude: - - 'lib/rspec/core/configuration.rb' - - 'lib/rspec/core/hooks.rb' - - 'lib/rspec/core/option_parser.rb' - - 'lib/rspec/core/pending.rb' - - 'spec/rspec/core/formatters/base_text_formatter_spec.rb' - # Offense count: 2 # Cop supports --auto-correct. Style/RandomWithOffset: diff --git a/benchmarks/call_v_yield.rb b/benchmarks/call_v_yield.rb index f6b1bfba62..b63b01d698 100644 --- a/benchmarks/call_v_yield.rb +++ b/benchmarks/call_v_yield.rb @@ -3,7 +3,7 @@ n = 100_000 def call_block(&block) - block.call + block.call # rubocop:disable Performance/RedundantBlockCall end def yield_control diff --git a/benchmarks/capture_block_vs_yield.rb b/benchmarks/capture_block_vs_yield.rb index 2705527678..ec173a7bff 100644 --- a/benchmarks/capture_block_vs_yield.rb +++ b/benchmarks/capture_block_vs_yield.rb @@ -8,6 +8,7 @@ def capture_block_and_yield(&block) yield end +# rubocop:disable Performance/RedundantBlockCall def capture_block_and_call(&block) block.call end @@ -59,6 +60,7 @@ def forward_block_to_n_times(n, &block) def call_block_n_times(n, &block) n.times { block.call } end +# rubocop:enable Performance/RedundantBlockCall [10, 25, 50, 100, 1000, 10000].each do |count| puts "Invoking the block #{count} times" diff --git a/benchmarks/singleton_example_groups/helper.rb b/benchmarks/singleton_example_groups/helper.rb index 8f543c1e25..7e93e18d18 100644 --- a/benchmarks/singleton_example_groups/helper.rb +++ b/benchmarks/singleton_example_groups/helper.rb @@ -34,8 +34,10 @@ def old_configure_example(*) class BenchmarkHelpers def self.prepare_implementation(prefix) RSpec.world = RSpec::Core::World.new # clear our state - RSpec::Core::Example.__send__ :alias_method, :with_around_and_singleton_context_hooks, :"#{prefix}_with_around_and_singleton_context_hooks" - RSpec::Core::Hooks::HookCollections.__send__ :alias_method, :register_global_singleton_context_hooks, :"#{prefix}_register_global_singleton_context_hooks" + RSpec::Core::Example.__send__ :alias_method, :with_around_and_singleton_context_hooks, + :"#{prefix}_with_around_and_singleton_context_hooks" + RSpec::Core::Hooks::HookCollections.__send__ :alias_method, :register_global_singleton_context_hooks, + :"#{prefix}_register_global_singleton_context_hooks" RSpec::Core::Configuration.__send__ :alias_method, :configure_example, :"#{prefix}_configure_example" end diff --git a/benchmarks/to_proc_v_not_to_proc.rb b/benchmarks/to_proc_v_not_to_proc.rb index e1e5c4cda0..6939fefa77 100644 --- a/benchmarks/to_proc_v_not_to_proc.rb +++ b/benchmarks/to_proc_v_not_to_proc.rb @@ -22,7 +22,7 @@ def a(&block) end def b(&block) - block.call + block.call # rubocop:disable Performance/RedundantBlockCall end def c(&block) diff --git a/features/step_definitions/additional_cli_steps.rb b/features/step_definitions/additional_cli_steps.rb index 68a5e6f605..11a3f9b1c1 100644 --- a/features/step_definitions/additional_cli_steps.rb +++ b/features/step_definitions/additional_cli_steps.rb @@ -220,7 +220,7 @@ seconds = '\d+(?:\.\d+)? seconds' expect(all_output).to match( - %r{Top 1 slowest example groups?:\n\s+slow before context hook\n\s+#{seconds} average \(#{seconds} / 1 example\) \./spec/example_spec\.rb:1} + %r{Top 1 slowest example groups?:\n\s+slow before context hook\n\s+#{seconds} average \(#{seconds} / 1 example\) \./spec/example_spec\.rb:1} # rubocop:disable Metrics/LineLength ) end diff --git a/rspec-core.gemspec b/rspec-core.gemspec index f4a44789ad..66ee915887 100644 --- a/rspec-core.gemspec +++ b/rspec-core.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.files += %w[README.md LICENSE.md Changelog.md .yardopts .document] s.test_files = [] s.bindir = 'exe' - s.executables = `git ls-files -- exe/*`.split("\n").map{ |f| File.basename(f) } + s.executables = `git ls-files -- exe/*`.split("\n").map { |f| File.basename(f) } s.rdoc_options = ["--charset=UTF-8"] s.require_path = "lib" diff --git a/script/rspec_with_simplecov b/script/rspec_with_simplecov index 92635dce93..cc8084e5f7 100755 --- a/script/rspec_with_simplecov +++ b/script/rspec_with_simplecov @@ -34,7 +34,7 @@ begin minimum_coverage(100) end end -rescue LoadError +rescue LoadError # rubocop:disable Lint/HandleExceptions ensure $VERBOSE = old_verbose end diff --git a/spec/rspec/core/drb_spec.rb b/spec/rspec/core/drb_spec.rb index 3086737166..b9ae8fa6f5 100644 --- a/spec/rspec/core/drb_spec.rb +++ b/spec/rspec/core/drb_spec.rb @@ -24,7 +24,7 @@ def config_options(*args) end describe "--drb-port" do - def with_RSPEC_DRB_set_to(val) + def with_RSPEC_DRB_set_to(val) # rubocop:disable Naming/MethodName with_env_vars('RSPEC_DRB' => val) { yield } end diff --git a/spec/rspec/core/example_group_spec.rb b/spec/rspec/core/example_group_spec.rb index 0b82292e17..32d54a5b3e 100644 --- a/spec/rspec/core/example_group_spec.rb +++ b/spec/rspec/core/example_group_spec.rb @@ -1727,7 +1727,7 @@ def extension_method; 17; end def foo; end end group.send(name, "named this with params", :a) - expect(group.public_instance_methods.map{|m| m.to_s}).to include("foo") + expect(group.public_instance_methods.map {|m| m.to_s}).to include("foo") end it "evals the shared example group only once" do @@ -1787,7 +1787,7 @@ def foo; "bar"; end def foo; end end shared_group = group.it_should_behave_like("thing") - expect(shared_group.public_instance_methods.map{|m| m.to_s}).to include("foo") + expect(shared_group.public_instance_methods.map {|m| m.to_s}).to include("foo") end it "adds shared class methods to nested group" do @@ -1796,7 +1796,7 @@ def foo; end def self.foo; end end shared_group = group.it_should_behave_like("thing") - expect(shared_group.methods.map{|m| m.to_s}).to include("foo") + expect(shared_group.methods.map {|m| m.to_s}).to include("foo") end it "passes parameters to the shared example group" do @@ -1824,7 +1824,7 @@ def self.foo; end def foo; end end shared_group = group.it_should_behave_like("thing", :a) - expect(shared_group.public_instance_methods.map{|m| m.to_s}).to include("foo") + expect(shared_group.public_instance_methods.map {|m| m.to_s}).to include("foo") end it "evals the shared example group only once" do diff --git a/spec/rspec/core/example_spec.rb b/spec/rspec/core/example_spec.rb index 5bba1d5627..d2f7c96a50 100644 --- a/spec/rspec/core/example_spec.rb +++ b/spec/rspec/core/example_spec.rb @@ -110,7 +110,7 @@ def metadata_hash(*args) begin example_group.run - rescue unhandled + rescue unhandled # rubocop:disable Lint/HandleExceptions # no-op, prevent from bubbling up end expect(example.execution_result.finished_at).not_to be_nil diff --git a/spec/rspec/core/formatters/base_text_formatter_spec.rb b/spec/rspec/core/formatters/base_text_formatter_spec.rb index bb52318f0d..0ee42393d9 100644 --- a/spec/rspec/core/formatters/base_text_formatter_spec.rb +++ b/spec/rspec/core/formatters/base_text_formatter_spec.rb @@ -181,7 +181,7 @@ def run_all_and_dump_failures context "with an exception class other than RSpec" do it "does not show the error class" do - group.example("example name") { raise NameError.new('foo') } + group.example("example name") { raise NameError.new('foo') } # rubocop:disable Style/RaiseArgs run_all_and_dump_failures expect(formatter_output.string).to match(/NameError/m) end diff --git a/spec/rspec/core/memoized_helpers_spec.rb b/spec/rspec/core/memoized_helpers_spec.rb index dc2da63f82..f33461af75 100644 --- a/spec/rspec/core/memoized_helpers_spec.rb +++ b/spec/rspec/core/memoized_helpers_spec.rb @@ -137,7 +137,7 @@ def working_with?(double) describe "defined in a top level group" do let(:group) do RSpec.describe do - subject{ [4, 5, 6] } + subject { [4, 5, 6] } end end diff --git a/spec/rspec/core/resources/utf8_encoded.rb b/spec/rspec/core/resources/utf8_encoded.rb index b173bce3b4..7ec87409bb 100644 --- a/spec/rspec/core/resources/utf8_encoded.rb +++ b/spec/rspec/core/resources/utf8_encoded.rb @@ -1,8 +1,8 @@ # encoding: utf-8 module Custom class ExampleUTF8ClassNameVarietà - def self.è - così = :però + def self.è # rubocop:disable Naming/MethodName + così = :però # rubocop:disable Naming/VariableName così end end diff --git a/spec/support/formatter_support.rb b/spec/support/formatter_support.rb index 8946859350..edb975900b 100644 --- a/spec/support/formatter_support.rb +++ b/spec/support/formatter_support.rb @@ -5,7 +5,7 @@ def run_example_specs_with_formatter(formatter_option, options={}, &block) return output unless options.fetch(:normalize_output, true) output = normalize_durations(output) - caller_line = RSpec::Core::Metadata.relative_path(caller.first) + caller_line = RSpec::Core::Metadata.relative_path(caller.first) # rubocop:disable Performance/Caller output.lines.reject do |line| # remove the direct caller as that line is different for the summary output backtraces line.include?(caller_line) || From 5fe4c0513f20e05fe456cfbfd64b44368c429083 Mon Sep 17 00:00:00 2001 From: Garett Arrowood Date: Sun, 21 Jan 2018 09:29:58 -0500 Subject: [PATCH 6/6] More rubocop adjustments Instead of inline using rubocop:disable on offending lines, this change follows the repo's convention of excluding files. This change also accounts for files generated during testing. --- .rubocop.yml | 13 ++++++++++++- benchmarks/call_v_yield.rb | 2 +- benchmarks/capture_block_vs_yield.rb | 2 -- benchmarks/to_proc_v_not_to_proc.rb | 2 +- script/rspec_with_simplecov | 2 +- spec/rspec/core/example_spec.rb | 2 +- .../core/formatters/base_text_formatter_spec.rb | 2 +- spec/support/formatter_support.rb | 2 +- 8 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e550072e9b..63a012ca4b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,9 @@ AllCops: Exclude: # This code was taken from the backports gem. We don't want to mess with it. - lib/rspec/core/backport_random.rb + - spec/rspec/core/bisect/shell_command_spec.rb + - spec/rspec/core/bisect/shell_runner_spec.rb + - 'tmp/**/*' # This should go down over time. Metrics/AbcSize: @@ -55,6 +58,8 @@ Lint/HandleExceptions: - lib/rspec/core/mocking_adapters/mocha.rb - lib/rspec/core/runner.rb - lib/rspec/core/test_unit_assertions_adapter.rb + - script/rspec_with_simplecov + - spec/rspec/core/example_spec.rb Lint/LiteralInInterpolation: Enabled: false @@ -62,6 +67,7 @@ Lint/LiteralInInterpolation: Lint/NonLocalExitFromIterator: Enabled: false +# Since we support Ruby 1.9-, 'encoding: utf-8' comments are meaningful. Style/Encoding: Enabled: false @@ -108,10 +114,14 @@ Style/RaiseArgs: - lib/rspec/core/hooks.rb - lib/rspec/core/option_parser.rb - lib/rspec/core/pending.rb + - spec/rspec/core/formatters/base_text_formatter_spec.rb Performance/RedundantBlockCall: Exclude: - lib/rspec/core/rake_task.rb + - benchmarks/call_v_yield.rb + - benchmarks/capture_block_vs_yield.rb + - benchmarks/to_proc_v_not_to_proc.rb Lint/IneffectiveAccessModifier: Exclude: @@ -123,7 +133,8 @@ Performance/Caller: # speed up can be substantial (previous optimization work I've done on # RSpec involved caller optimization) but I haven't benchmarked this # particular case to see if it's worth introducing version branching. - - 'lib/rspec/core/example_group.rb' + - lib/rspec/core/example_group.rb + - spec/support/formatter_support.rb Layout/SpaceBeforeBlockBraces: EnforcedStyle: space diff --git a/benchmarks/call_v_yield.rb b/benchmarks/call_v_yield.rb index b63b01d698..f6b1bfba62 100644 --- a/benchmarks/call_v_yield.rb +++ b/benchmarks/call_v_yield.rb @@ -3,7 +3,7 @@ n = 100_000 def call_block(&block) - block.call # rubocop:disable Performance/RedundantBlockCall + block.call end def yield_control diff --git a/benchmarks/capture_block_vs_yield.rb b/benchmarks/capture_block_vs_yield.rb index ec173a7bff..2705527678 100644 --- a/benchmarks/capture_block_vs_yield.rb +++ b/benchmarks/capture_block_vs_yield.rb @@ -8,7 +8,6 @@ def capture_block_and_yield(&block) yield end -# rubocop:disable Performance/RedundantBlockCall def capture_block_and_call(&block) block.call end @@ -60,7 +59,6 @@ def forward_block_to_n_times(n, &block) def call_block_n_times(n, &block) n.times { block.call } end -# rubocop:enable Performance/RedundantBlockCall [10, 25, 50, 100, 1000, 10000].each do |count| puts "Invoking the block #{count} times" diff --git a/benchmarks/to_proc_v_not_to_proc.rb b/benchmarks/to_proc_v_not_to_proc.rb index 6939fefa77..e1e5c4cda0 100644 --- a/benchmarks/to_proc_v_not_to_proc.rb +++ b/benchmarks/to_proc_v_not_to_proc.rb @@ -22,7 +22,7 @@ def a(&block) end def b(&block) - block.call # rubocop:disable Performance/RedundantBlockCall + block.call end def c(&block) diff --git a/script/rspec_with_simplecov b/script/rspec_with_simplecov index cc8084e5f7..92635dce93 100755 --- a/script/rspec_with_simplecov +++ b/script/rspec_with_simplecov @@ -34,7 +34,7 @@ begin minimum_coverage(100) end end -rescue LoadError # rubocop:disable Lint/HandleExceptions +rescue LoadError ensure $VERBOSE = old_verbose end diff --git a/spec/rspec/core/example_spec.rb b/spec/rspec/core/example_spec.rb index d2f7c96a50..5bba1d5627 100644 --- a/spec/rspec/core/example_spec.rb +++ b/spec/rspec/core/example_spec.rb @@ -110,7 +110,7 @@ def metadata_hash(*args) begin example_group.run - rescue unhandled # rubocop:disable Lint/HandleExceptions + rescue unhandled # no-op, prevent from bubbling up end expect(example.execution_result.finished_at).not_to be_nil diff --git a/spec/rspec/core/formatters/base_text_formatter_spec.rb b/spec/rspec/core/formatters/base_text_formatter_spec.rb index 0ee42393d9..bb52318f0d 100644 --- a/spec/rspec/core/formatters/base_text_formatter_spec.rb +++ b/spec/rspec/core/formatters/base_text_formatter_spec.rb @@ -181,7 +181,7 @@ def run_all_and_dump_failures context "with an exception class other than RSpec" do it "does not show the error class" do - group.example("example name") { raise NameError.new('foo') } # rubocop:disable Style/RaiseArgs + group.example("example name") { raise NameError.new('foo') } run_all_and_dump_failures expect(formatter_output.string).to match(/NameError/m) end diff --git a/spec/support/formatter_support.rb b/spec/support/formatter_support.rb index edb975900b..8946859350 100644 --- a/spec/support/formatter_support.rb +++ b/spec/support/formatter_support.rb @@ -5,7 +5,7 @@ def run_example_specs_with_formatter(formatter_option, options={}, &block) return output unless options.fetch(:normalize_output, true) output = normalize_durations(output) - caller_line = RSpec::Core::Metadata.relative_path(caller.first) # rubocop:disable Performance/Caller + caller_line = RSpec::Core::Metadata.relative_path(caller.first) output.lines.reject do |line| # remove the direct caller as that line is different for the summary output backtraces line.include?(caller_line) ||