Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MultipleMemoizedHelpers cop #863

Merged
merged 9 commits into from Aug 9, 2020
Merged

Add MultipleMemoizedHelpers cop #863

merged 9 commits into from Aug 9, 2020

Commits on Aug 7, 2020

  1. Add NoLet cop

    mockdeep authored and pirj committed Aug 7, 2020
    Copy the full SHA
    74dde0e View commit details
    Browse the repository at this point in the history

Commits on Aug 8, 2020

  1. Rename the cop

    and fix the build
    pirj committed Aug 8, 2020
    Copy the full SHA
    d761fc3 View commit details
    Browse the repository at this point in the history
  2. Minor restyling

    pirj committed Aug 8, 2020
    Copy the full SHA
    3732a9c View commit details
    Browse the repository at this point in the history
  3. Update the manual

    pirj committed Aug 8, 2020
    Copy the full SHA
    418c7fc View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    3fcd0bb View commit details
    Browse the repository at this point in the history
  5. Allow for --auto-gen-config

    pirj committed Aug 8, 2020
    Copy the full SHA
    c3ab68f View commit details
    Browse the repository at this point in the history
  6. Copy the full SHA
    8d7b3c9 View commit details
    Browse the repository at this point in the history
  7. Enable MultipleMemoizedHelpers by default

    Switching the cop on by default to match RSpec recommendations from its
    docs and the community RSpec Style Guide recommendations.
    
        `let` _can_ enhance readability when used sparingly (1,2, or
        maybe 3 declarations) in any given example group, but that can
        quickly degrade with overuse. YMMV.
    
    https://github.com/rspec/rspec-core/blob/5d87c28bb828ba14b54a0d8cfddf044894009314/lib/rspec/core/memoized_helpers.rb#L257
    
    https://reddit.com/r/ruby/comments/73nrhk/ama_the_authors_of_effective_testing_with_rspec_3/dnsyanp/
    
    https://rspec.rubystyle.guide/#let-blocks
    
    Example change to dramatically reduce the number of used memoized
    helpers without resorting to methods rubocop/rubocop#8447
    
    There is no limit to the number of memoized helpers being used in
    practice:
    
    10 lets https://github.com/forem/forem/blob/master/spec/support/api_analytics_shared_examples.rb#L2
    20 lets https://github.com/chef/chef/blob/master/spec/unit/provider/systemd_unit_spec.rb#L23
    30 lets https://github.com/chef/chef/blob/master/spec/unit/policy_builder/policyfile_spec.rb#L24
    40 lets https://github.com/diaspora/diaspora/blob/develop/spec/integration/migration_service_spec.rb#L7
    50 lets https://github.com/chef/chef/blob/master/spec/functional/resource/dsc_script_spec.rb#L71
    
    Allowing `subject` by default, i.e. subjects don't count towards the
    number of memoized helpers, since there is a dedicated
    `RSpec/MultipleSubjects` cop. Combination with it provides infinite
    possibilities to tweak the maximum allowed number of memoized helpers to
    meet the project style.
    pirj committed Aug 8, 2020
    Copy the full SHA
    edb87e8 View commit details
    Browse the repository at this point in the history

Commits on Aug 9, 2020

  1. Improve the performance of MultipleMemoizedHelpers

    Fetching memoized helpers for each of the ancestors is not optimal, is
    not optimal and has non-linear complexity.
    pirj committed Aug 9, 2020
    Copy the full SHA
    986537f View commit details
    Browse the repository at this point in the history