Sha256: a9bc4379d5a63bf82f835ae4bd6129ceed2eddd20d79240feef2fe671e62f13d

Contents?: true

Size: 1.99 KB

Versions: 16

Compression:

Stored size: 1.99 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:
      """
      ---
      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` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
    """

  Scenario: Use regexes for excluding contexts
    Given a file named "config.reek" with:
      """
      ---
      IrresponsibleModule:
        enabled: false
      UnusedPrivateMethod:
        enabled: true
        exclude:
          - !ruby/regexp /(.*)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` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
    """

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
reek-4.4.0 features/configuration_files/unused_private_method.feature
reek-4.3.0 features/configuration_files/unused_private_method.feature
reek-4.2.5 features/configuration_files/unused_private_method.feature
reek-4.2.4 features/configuration_files/unused_private_method.feature
reek-4.2.3 features/configuration_files/unused_private_method.feature
reek-4.2.2 features/configuration_files/unused_private_method.feature
reek-4.2.1 features/configuration_files/unused_private_method.feature
reek-4.2.0 features/configuration_files/unused_private_method.feature
reek-4.1.1 features/configuration_files/unused_private_method.feature
reek-4.1.0 features/configuration_files/unused_private_method.feature
reek-4.0.5 features/configuration_files/unused_private_method.feature
reek-4.0.4 features/configuration_files/unused_private_method.feature
reek-4.0.3 features/configuration_files/unused_private_method.feature
reek-4.0.2 features/configuration_files/unused_private_method.feature
reek-4.0.1 features/configuration_files/unused_private_method.feature
reek-4.0.0 features/configuration_files/unused_private_method.feature