diff --git a/.rubocop.yml b/.rubocop.yml index 29d6341570..63a012ca4b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,37 +1,56 @@ inherit_from: + - .rubocop_todo.yml - .rubocop_rspec_base.yml 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/ClassLength: - Max: 330 +Metrics/AbcSize: + Max: 40 + Exclude: + - 'spec/**/*' -Encoding: +Metrics/BlockLength: + Max: 193 Exclude: - - lib/rspec/core/formatters/exception_presenter.rb + - 'spec/**/*' # This should go down over time. -Metrics/AbcSize: - Max: 40 +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: @@ -39,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 @@ -46,6 +67,10 @@ Lint/LiteralInInterpolation: Lint/NonLocalExitFromIterator: Enabled: false +# Since we support Ruby 1.9-, 'encoding: utf-8' comments are meaningful. +Style/Encoding: + Enabled: false + # We don't care about single vs double qoutes. Style/StringLiteralsInInterpolation: Enabled: false @@ -89,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: @@ -104,7 +133,9 @@ 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 -Metrics/BlockLength: - Max: 193 +Layout/SpaceBeforeBlockBraces: + EnforcedStyle: space + EnforcedStyleForEmptyBraces: space diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000000..e4940980b0 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,656 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# 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 +# 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: 16 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + 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. +# 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/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: 3 +Naming/AsciiIdentifiers: + Exclude: + - 'spec/rspec/core/resources/utf8_encoded.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: 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: 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: 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' 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/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/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/lib/rspec/core/formatters/html_printer.rb b/lib/rspec/core/formatters/html_printer.rb index 16f96df659..69e089eb68 100644 --- a/lib/rspec/core/formatters/html_printer.rb +++ b/lib/rspec/core/formatters/html_printer.rb @@ -36,7 +36,6 @@ def print_example_passed(description, run_time) # 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 "