Sha256: 5ac3cf11a86cc4610a48da36d89293b0d5e9e3eefd81e0c9c2d0fad3a6a696ee

Contents?: true

Size: 1.86 KB

Versions: 20

Compression:

Stored size: 1.86 KB

Contents

Feature: Unused Private Method detector
  This detector is a little special in the sense that it takes class contexts but analyzes
  methods (and thus, is configured in regards to methods) so we need to make sure
  that our configuration handling still works.

  Scenario: Differentiate between contexts when excluding them
    Given a file named "config.reek" with:
      """
      ---
      detectors:
        IrresponsibleModule:
          enabled: false
        UnusedPrivateMethod:
          enabled: true
          exclude:
            - Outer::Awesome#foobar
      """
    And a file named "sample.rb" with:
      """
      module Outer
        class Smelly
          private
          def foobar; end # Should report UnusedPrivateMethod
        end
        class Awesome
          private
          def foobar; end # Should not report UnusedPrivateMethod
        end
      end
      """
    When I run reek -c config.reek sample.rb
    Then it reports:
    """
    sample.rb -- 1 warning:
      [4]:UnusedPrivateMethod: Outer::Smelly has the unused private instance method 'foobar'
    """

  Scenario: Use regexes for excluding contexts
    Given a file named "config.reek" with:
      """
      ---
      detectors:
        IrresponsibleModule:
          enabled: false
        UnusedPrivateMethod:
          enabled: true
          exclude:
            - wesome#foo
      """
    And a file named "sample.rb" with:
      """
      module Outer
        class Smelly
          private
          def foobar; end # Should report UnusedPrivateMethod
        end
        class Awesome
          private
          def foobar; end # Should not report UnusedPrivateMethod
        end
      end
      """
    When I run reek -c config.reek sample.rb
    Then it reports:
    """
    sample.rb -- 1 warning:
      [4]:UnusedPrivateMethod: Outer::Smelly has the unused private instance method 'foobar'
    """

Version data entries

20 entries across 18 versions & 2 rubygems

Version Path
reek-6.0.3 features/configuration_files/unused_private_method.feature
reek-6.0.2 features/configuration_files/unused_private_method.feature
reek-6.0.1 features/configuration_files/unused_private_method.feature
reek-6.0.0 features/configuration_files/unused_private_method.feature
reek-5.6.0 features/configuration_files/unused_private_method.feature
reek-5.5.0 features/configuration_files/unused_private_method.feature
reek-5.4.1 features/configuration_files/unused_private_method.feature
reek-5.4.0 features/configuration_files/unused_private_method.feature
reek-5.3.2 features/configuration_files/unused_private_method.feature
reek-5.3.1 features/configuration_files/unused_private_method.feature
reek-5.3.0 features/configuration_files/unused_private_method.feature
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/features/configuration_files/unused_private_method.feature
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/features/configuration_files/unused_private_method.feature
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/features/configuration_files/unused_private_method.feature
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/features/configuration_files/unused_private_method.feature
reek-5.2.0 features/configuration_files/unused_private_method.feature
reek-5.1.0 features/configuration_files/unused_private_method.feature
reek-5.0.2 features/configuration_files/unused_private_method.feature
reek-5.0.1 features/configuration_files/unused_private_method.feature
reek-5.0.0 features/configuration_files/unused_private_method.feature