reek 3.3.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/CHANGELOG.md +6 -0
  4. data/CONTRIBUTING.md +3 -0
  5. data/README.md +12 -4
  6. data/Rakefile +1 -0
  7. data/config/defaults.reek +1 -2
  8. data/docs/Nested-Iterators.md +6 -1
  9. data/docs/Smell-Suppression.md +69 -5
  10. data/docs/Uncommunicative-Module-Name.md +1 -1
  11. data/docs/Utility-Function.md +13 -1
  12. data/docs/style-guide.md +18 -0
  13. data/docs/templates/default/docstring/html/public_api_marker.erb +3 -0
  14. data/docs/templates/default/docstring/setup.rb +41 -0
  15. data/docs/templates/default/fulldoc/html/css/common.css +1 -0
  16. data/docs/yard_plugin.rb +2 -0
  17. data/features/command_line_interface/smell_selection.feature +1 -0
  18. data/features/configuration_files/masking_smells.feature +12 -0
  19. data/features/samples.feature +27 -26
  20. data/features/step_definitions/sample_file_steps.rb +25 -30
  21. data/lib/reek/ast/ast_node_class_map.rb +1 -1
  22. data/lib/reek/ast/node.rb +3 -4
  23. data/lib/reek/ast/object_refs.rb +2 -2
  24. data/lib/reek/ast/reference_collector.rb +0 -1
  25. data/lib/reek/ast/sexp_extensions.rb +1 -2
  26. data/lib/reek/ast/sexp_formatter.rb +1 -2
  27. data/lib/reek/cli/application.rb +0 -1
  28. data/lib/reek/cli/command.rb +0 -1
  29. data/lib/reek/cli/input.rb +2 -1
  30. data/lib/reek/cli/option_interpreter.rb +0 -1
  31. data/lib/reek/cli/options.rb +3 -1
  32. data/lib/reek/cli/reek_command.rb +0 -1
  33. data/lib/reek/cli/silencer.rb +4 -4
  34. data/lib/reek/cli/warning_collector.rb +0 -1
  35. data/lib/reek/code_comment.rb +6 -11
  36. data/lib/reek/configuration/app_configuration.rb +0 -3
  37. data/lib/reek/configuration/configuration_file_finder.rb +4 -1
  38. data/lib/reek/configuration/configuration_validator.rb +1 -0
  39. data/lib/reek/configuration/directory_directives.rb +4 -0
  40. data/lib/reek/configuration/excluded_paths.rb +2 -1
  41. data/lib/reek/context/code_context.rb +11 -4
  42. data/lib/reek/context/method_context.rb +1 -6
  43. data/lib/reek/context/module_context.rb +0 -1
  44. data/lib/reek/context/root_context.rb +0 -1
  45. data/lib/reek/context/singleton_method_context.rb +0 -1
  46. data/lib/reek/examiner.rb +15 -15
  47. data/lib/reek/rake/task.rb +14 -0
  48. data/lib/reek/report.rb +0 -8
  49. data/lib/reek/report/formatter.rb +13 -12
  50. data/lib/reek/report/heading_formatter.rb +2 -1
  51. data/lib/reek/report/location_formatter.rb +0 -3
  52. data/lib/reek/report/report.rb +34 -14
  53. data/lib/reek/smells/attribute.rb +6 -6
  54. data/lib/reek/smells/boolean_parameter.rb +8 -8
  55. data/lib/reek/smells/class_variable.rb +7 -6
  56. data/lib/reek/smells/control_parameter.rb +8 -7
  57. data/lib/reek/smells/data_clump.rb +18 -20
  58. data/lib/reek/smells/duplicate_method_call.rb +10 -6
  59. data/lib/reek/smells/feature_envy.rb +17 -9
  60. data/lib/reek/smells/irresponsible_module.rb +6 -6
  61. data/lib/reek/smells/long_parameter_list.rb +7 -7
  62. data/lib/reek/smells/long_yield_list.rb +10 -9
  63. data/lib/reek/smells/module_initialize.rb +7 -6
  64. data/lib/reek/smells/nested_iterators.rb +5 -6
  65. data/lib/reek/smells/nil_check.rb +4 -5
  66. data/lib/reek/smells/prima_donna_method.rb +5 -5
  67. data/lib/reek/smells/repeated_conditional.rb +9 -6
  68. data/lib/reek/smells/smell_configuration.rb +1 -7
  69. data/lib/reek/smells/smell_detector.rb +28 -25
  70. data/lib/reek/smells/smell_repository.rb +18 -19
  71. data/lib/reek/smells/smell_warning.rb +34 -21
  72. data/lib/reek/smells/too_many_instance_variables.rb +5 -6
  73. data/lib/reek/smells/too_many_methods.rb +6 -6
  74. data/lib/reek/smells/too_many_statements.rb +5 -6
  75. data/lib/reek/smells/uncommunicative_method_name.rb +6 -6
  76. data/lib/reek/smells/uncommunicative_module_name.rb +36 -22
  77. data/lib/reek/smells/uncommunicative_parameter_name.rb +27 -19
  78. data/lib/reek/smells/uncommunicative_variable_name.rb +13 -7
  79. data/lib/reek/smells/unused_parameters.rb +10 -9
  80. data/lib/reek/smells/utility_function.rb +22 -11
  81. data/lib/reek/source/source_code.rb +11 -12
  82. data/lib/reek/source/source_locator.rb +6 -1
  83. data/lib/reek/spec.rb +11 -0
  84. data/lib/reek/spec/should_reek.rb +0 -3
  85. data/lib/reek/spec/should_reek_of.rb +1 -1
  86. data/lib/reek/spec/should_reek_only_of.rb +0 -1
  87. data/lib/reek/tree_dresser.rb +3 -1
  88. data/lib/reek/tree_walker.rb +4 -5
  89. data/lib/reek/version.rb +4 -1
  90. data/reek.gemspec +1 -1
  91. data/spec/factories/factories.rb +17 -6
  92. data/spec/quality/reek_source_spec.rb +3 -1
  93. data/spec/reek/cli/warning_collector_spec.rb +3 -2
  94. data/spec/reek/code_comment_spec.rb +8 -10
  95. data/spec/reek/configuration/directory_directives_spec.rb +2 -2
  96. data/spec/reek/configuration/excluded_paths_spec.rb +2 -2
  97. data/spec/reek/context/method_context_spec.rb +0 -26
  98. data/spec/reek/report/json_report_spec.rb +83 -6
  99. data/spec/reek/report/yaml_report_spec.rb +76 -6
  100. data/spec/reek/smells/attribute_spec.rb +1 -1
  101. data/spec/reek/smells/boolean_parameter_spec.rb +2 -3
  102. data/spec/reek/smells/class_variable_spec.rb +1 -1
  103. data/spec/reek/smells/control_parameter_spec.rb +1 -1
  104. data/spec/reek/smells/data_clump_spec.rb +1 -1
  105. data/spec/reek/smells/duplicate_method_call_spec.rb +1 -1
  106. data/spec/reek/smells/feature_envy_spec.rb +1 -0
  107. data/spec/reek/smells/irresponsible_module_spec.rb +1 -1
  108. data/spec/reek/smells/long_parameter_list_spec.rb +1 -1
  109. data/spec/reek/smells/long_yield_list_spec.rb +1 -1
  110. data/spec/reek/smells/nested_iterators_spec.rb +1 -1
  111. data/spec/reek/smells/repeated_conditional_spec.rb +1 -1
  112. data/spec/reek/smells/smell_configuration_spec.rb +9 -9
  113. data/spec/reek/smells/smell_detector_shared.rb +0 -9
  114. data/spec/reek/smells/smell_repository_spec.rb +1 -8
  115. data/spec/reek/smells/smell_warning_spec.rb +3 -2
  116. data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
  117. data/spec/reek/smells/too_many_methods_spec.rb +2 -4
  118. data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -1
  119. data/spec/reek/smells/uncommunicative_module_name_spec.rb +22 -5
  120. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +1 -1
  121. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +1 -1
  122. data/spec/reek/smells/utility_function_spec.rb +49 -0
  123. metadata +9 -5
@@ -72,25 +72,6 @@ Given(/^a smelly file called 'smelly.rb'( in a subdirectory)?$/) do |in_subdir|
72
72
  EOS
73
73
  end
74
74
 
75
- Given(/^a file with smelly variable names called 'camel_case.rb'$/) do
76
- write_file('camel_case.rb', <<-EOS.strip_heredoc)
77
- # Class containing camelCase variable which would normally smell
78
- class CamelCase
79
- def initialize
80
- # These next two would normally smell if it weren't for overridden config values
81
- camelCaseVariable = []
82
- anotherOne = 1
83
-
84
- # this next one should still smell
85
- x1 = 0
86
-
87
- # this next one should not smell
88
- should_not_smell = true
89
- end
90
- end
91
- EOS
92
- end
93
-
94
75
  Given(/^an empty configuration file called 'empty.reek'$/) do
95
76
  write_file('empty.reek', '')
96
77
  end
@@ -118,17 +99,6 @@ Given(/^a configuration file masking some duplication smells called 'config.reek
118
99
  EOS
119
100
  end
120
101
 
121
- Given(/^a configuration file allowing camel case variables$/) do
122
- write_file('config.reek', <<-EOS.strip_heredoc)
123
- ---
124
- UncommunicativeVariableName:
125
- enabled: true
126
- reject:
127
- - !ruby/regexp /^.$/
128
- - !ruby/regexp /[0-9]$/
129
- EOS
130
- end
131
-
132
102
  When(/^I run "reek (.*?)" in the subdirectory$/) do |args|
133
103
  cd 'subdir'
134
104
  reek(args)
@@ -156,3 +126,28 @@ Given(/^an enabling configuration file in the subdirectory$/) do
156
126
  enabled: true
157
127
  EOS
158
128
  end
129
+
130
+ Given(/^a smelly file called 'smelly.rb' with private, protected and public UtilityFunction methods$/) do
131
+ write_file 'smelly.rb', <<-EOS.strip_heredoc
132
+ # smelly class for testing purposes
133
+ class Klass
134
+ def public_method(arg) arg.to_s; end
135
+ protected
136
+ def protected_method(arg) arg.to_s; end
137
+ private
138
+ def private_method(arg) arg.to_s; end
139
+ end
140
+ EOS
141
+ end
142
+
143
+ Given(/^a configuration file disabling UtilityFunction for non-public methods called 'config.reek'$/) do
144
+ write_file('config.reek', <<-EOS.strip_heredoc)
145
+ ---
146
+ UtilityFunction:
147
+ public_methods_only: true
148
+ EOS
149
+ end
150
+
151
+ Then(/^it does not report private or protected methods$/) do
152
+ # Pseudo step for feature clarity.
153
+ end
@@ -6,7 +6,6 @@ module Reek
6
6
  # Maps AST node types to sublasses of ASTNode extended with the relevant
7
7
  # utility modules.
8
8
  #
9
- # @api private
10
9
  class ASTNodeClassMap
11
10
  def initialize
12
11
  @klass_map = {}
@@ -15,6 +14,7 @@ module Reek
15
14
  def klass_for(type)
16
15
  klass_map[type] ||= Class.new(Node).tap do |klass|
17
16
  extension = extension_map[type]
17
+ # TODO: map node type to constant directly.
18
18
  klass.send :include, extension if extension
19
19
  end
20
20
  end
data/lib/reek/ast/node.rb CHANGED
@@ -1,17 +1,15 @@
1
1
  require 'private_attr/everywhere'
2
2
  require_relative '../cli/silencer'
3
3
 
4
- Reek::CLI::Silencer.silently stderr: true, stdout: true do
4
+ Reek::CLI::Silencer.silently do
5
5
  require 'parser'
6
6
  end
7
7
 
8
8
  module Reek
9
- # @api private
10
9
  module AST
11
10
  # Base class for AST nodes extended with utility methods. Contains some
12
11
  # methods to ease the transition from Sexp to AST::Node.
13
12
  #
14
- # @api private
15
13
  class Node < ::Parser::AST::Node
16
14
  attr_reader :parent
17
15
 
@@ -39,7 +37,7 @@ module Reek
39
37
  end
40
38
 
41
39
  def line
42
- loc.line unless loc.nil?
40
+ loc && loc.line
43
41
  end
44
42
 
45
43
  # @deprecated
@@ -62,6 +60,7 @@ module Reek
62
60
  # context.each_node(:lvar).any? { |it| it.var_name == 'something' }
63
61
  #
64
62
  # Returns an array with all matching nodes.
63
+ # TODO: without a block, this doesn't do what one might expect
65
64
  def each_node(target_type, ignoring = [], &blk)
66
65
  if block_given?
67
66
  look_for_type(target_type, ignoring, &blk)
@@ -1,9 +1,9 @@
1
1
  require 'private_attr/everywhere'
2
2
 
3
3
  module Reek
4
- # @api private
4
+ # Represents functionality related to an Abstract Syntax Tree.
5
5
  module AST
6
- # Responsible for holding one specific object reference
6
+ # Responsible for holding one specific object reference.
7
7
  ObjectRef = Struct.new(:name, :line)
8
8
  #
9
9
  # Manages and counts the references out of a method to other objects.
@@ -6,7 +6,6 @@ module Reek
6
6
  # Locates references to the current object within a portion
7
7
  # of an abstract syntax tree.
8
8
  #
9
- # @api private
10
9
  class ReferenceCollector
11
10
  STOP_NODES = [:class, :module, :def, :defs]
12
11
 
@@ -6,7 +6,6 @@ module Reek
6
6
  # Extension modules providing utility methods to ASTNode objects, depending
7
7
  # on their type.
8
8
  #
9
- # @api private
10
9
  module SexpExtensions
11
10
  # Base module for utility methods for argument nodes.
12
11
  module ArgNodeBase
@@ -423,7 +422,7 @@ module Reek
423
422
  MODULE_DEFINERS = [:Class, :Struct]
424
423
 
425
424
  def defines_module?
426
- return false if value.nil?
425
+ return false unless value
427
426
  call = case value.type
428
427
  when :block
429
428
  value.call
@@ -1,6 +1,6 @@
1
1
  require_relative '../cli/silencer'
2
2
 
3
- Reek::CLI::Silencer.silently stderr: true, stdout: true do
3
+ Reek::CLI::Silencer.silently do
4
4
  require 'unparser'
5
5
  end
6
6
 
@@ -9,7 +9,6 @@ module Reek
9
9
  #
10
10
  # Formats snippets of syntax tree back into Ruby source code.
11
11
  #
12
- # @api private
13
12
  class SexpFormatter
14
13
  # Formats the given sexp.
15
14
  #
@@ -9,7 +9,6 @@ module Reek
9
9
  # This is the entry point for all invocations of Reek from the
10
10
  # command line.
11
11
  #
12
- # @api private
13
12
  class Application
14
13
  STATUS_SUCCESS = 0
15
14
  STATUS_ERROR = 1
@@ -5,7 +5,6 @@ module Reek
5
5
  #
6
6
  # Base class for all commands
7
7
  #
8
- # @api private
9
8
  class Command
10
9
  attr_reader :options
11
10
 
@@ -5,7 +5,6 @@ module Reek
5
5
  #
6
6
  # CLI Input utility
7
7
  #
8
- # @api private
9
8
  module Input
10
9
  def sources
11
10
  if no_source_files_given?
@@ -21,6 +20,7 @@ module Reek
21
20
 
22
21
  private
23
22
 
23
+ # :reek:UtilityFunction
24
24
  def input_was_piped?
25
25
  !$stdin.tty?
26
26
  end
@@ -31,6 +31,7 @@ module Reek
31
31
  argv.empty?
32
32
  end
33
33
 
34
+ # :reek:UtilityFunction
34
35
  def working_directory_as_source
35
36
  Source::SourceLocator.new(['.']).sources
36
37
  end
@@ -7,7 +7,6 @@ module Reek
7
7
  #
8
8
  # Interprets the options set from the command line
9
9
  #
10
- # @api private
11
10
  class OptionInterpreter
12
11
  include Input
13
12
 
@@ -10,7 +10,6 @@ module Reek
10
10
  # Parses the command line
11
11
  #
12
12
  # See {file:docs/Command-Line-Options.md} for details.
13
- # @api private
14
13
  class Options
15
14
  def initialize(argv = [])
16
15
  @argv = argv
@@ -33,6 +32,7 @@ module Reek
33
32
 
34
33
  private_attr_reader :argv, :options, :parser
35
34
 
35
+ # :reek:UtilityFunction
36
36
  def color_support?
37
37
  $stdout.tty?
38
38
  end
@@ -72,6 +72,7 @@ module Reek
72
72
  end
73
73
  end
74
74
 
75
+ # :reek:TooManyStatements: { max_statements: 6 }
75
76
  def set_configuration_options
76
77
  parser.separator 'Configuration:'
77
78
  parser.on('-c', '--config FILE', 'Read configuration options from FILE') do |file|
@@ -128,6 +129,7 @@ module Reek
128
129
  end
129
130
  end
130
131
 
132
+ # :reek:TooManyStatements: { max_statements: 7 }
131
133
  def set_utility_options
132
134
  parser.separator "\nUtility options:"
133
135
  parser.on_tail('-h', '--help', 'Show this message') do
@@ -7,7 +7,6 @@ module Reek
7
7
  # A command to collect smells from a set of sources and write them out in
8
8
  # text report format.
9
9
  #
10
- # @api private
11
10
  class ReekCommand < Command
12
11
  def execute(app)
13
12
  options.sources.each do |source|
@@ -3,15 +3,15 @@ require 'stringio'
3
3
  module Reek
4
4
  module CLI
5
5
  # CLI silencer
6
- # @api private
7
6
  module Silencer
8
7
  module_function
9
8
 
10
- def silently(stderr: nil, stdout: nil)
9
+ # :reek:TooManyStatements: { max_statements: 7 }
10
+ def silently
11
11
  old_verbose = $VERBOSE
12
12
  $VERBOSE = false
13
- $stderr = StringIO.new if stderr
14
- $stdout = StringIO.new if stdout
13
+ $stderr = StringIO.new
14
+ $stdout = StringIO.new
15
15
  yield
16
16
  ensure
17
17
  $VERBOSE = old_verbose
@@ -6,7 +6,6 @@ module Reek
6
6
  #
7
7
  # Collects and sorts smells warnings.
8
8
  #
9
- # @api private
10
9
  class WarningCollector
11
10
  def initialize
12
11
  @warnings_set = Set.new
@@ -9,36 +9,31 @@ module Reek
9
9
  # A comment header from an abstract syntax tree; found directly above
10
10
  # module, class and method definitions.
11
11
  #
12
- # @api private
13
12
  class CodeComment
14
13
  CONFIG_REGEX = /:reek:(\w+)(:\s*\{.*?\})?/
15
14
 
16
15
  def initialize(text)
16
+ @config = Hash.new { |hash, key| hash[key] = {} }
17
17
  @text = text.gsub(CONFIG_REGEX) do
18
- add_to_config($1, $2)
18
+ @config.merge! add_to_config($1, $2)
19
19
  ''
20
20
  end.gsub(/#/, '').gsub(/\n/, '').strip
21
21
  end
22
22
 
23
- def config
24
- @config ||= Hash.new { |hash, key| hash[key] = {} }
25
- end
23
+ attr_reader :config
26
24
 
27
25
  def descriptive?
28
26
  text.split(/\s+/).length >= 2
29
27
  end
30
28
 
31
- protected
29
+ private
32
30
 
31
+ # :reek:UtilityFunction
33
32
  def add_to_config(smell, options)
34
33
  options ||= ': { enabled: false }'
35
- config.merge! YAML.load(smell.gsub(/(?:^|_)(.)/) { $1.upcase } + options)
36
- # TODO: extend this to all configs -------------------^
37
- # TODO: extend to allow configuration of whole smell class, not just subclass
34
+ YAML.load(smell + options)
38
35
  end
39
36
 
40
- private
41
-
42
37
  private_attr_reader :text
43
38
  end
44
39
  end
@@ -7,13 +7,10 @@ require_relative './directory_directives'
7
7
  require_relative './excluded_paths'
8
8
 
9
9
  module Reek
10
- # @api private
11
10
  module Configuration
12
- # @api private
13
11
  #
14
12
  # Reek's singleton configuration instance.
15
13
  #
16
- # @api private
17
14
  class AppConfiguration
18
15
  include ConfigurationValidator
19
16
  EXCLUDE_PATHS_KEY = 'exclude_paths'
@@ -2,6 +2,7 @@ require 'pathname'
2
2
 
3
3
  module Reek
4
4
  module Configuration
5
+ # Raised when config file is not properly readable.
5
6
  class ConfigFileException < StandardError; end
6
7
  #
7
8
  # ConfigurationFileFinder is responsible for finding reek's configuration.
@@ -14,7 +15,6 @@ module Reek
14
15
  #
15
16
  # The order in which ConfigurationFileFinder tries to find such a
16
17
  # configuration file is exactly like above.
17
- # @api private
18
18
  module ConfigurationFileFinder
19
19
  module_function
20
20
 
@@ -22,10 +22,12 @@ module Reek
22
22
  load_from_file(find(path: path))
23
23
  end
24
24
 
25
+ # :reek:ControlParameter
25
26
  def find(path: nil, current: Pathname.pwd, home: Pathname.new(Dir.home))
26
27
  path || find_by_dir(current) || find_by_dir(home)
27
28
  end
28
29
 
30
+ # :reek:NestedIterators: { max_allowed_nesting: 2 }
29
31
  def find_by_dir(start)
30
32
  start.ascend do |dir|
31
33
  files = dir.children.select(&:file?).sort
@@ -34,6 +36,7 @@ module Reek
34
36
  end
35
37
  end
36
38
 
39
+ # :reek:TooManyStatements: { max_statements: 6 }
37
40
  def load_from_file(path)
38
41
  return {} unless path
39
42
  begin
@@ -6,6 +6,7 @@ module Reek
6
6
  module ConfigurationValidator
7
7
  private
8
8
 
9
+ # :reek:UtilityFunction
9
10
  def smell_type?(key)
10
11
  Reek::Smells.const_get key
11
12
  rescue NameError
@@ -26,6 +26,8 @@ module Reek
26
26
  # @param config [Hash] the configuration
27
27
  #
28
28
  # @return [self]
29
+ #
30
+ # :reek:NestedIterators: { max_allowed_nesting: 2 }
29
31
  def add(path, config)
30
32
  with_valid_directory(path) do |directory|
31
33
  self[directory] = config.each_with_object({}) do |(key, value), hash|
@@ -38,6 +40,8 @@ module Reek
38
40
 
39
41
  private
40
42
 
43
+ # :reek:DuplicateMethodCall: { max_calls: 2 }
44
+ # :reek:FeatureEnvy
41
45
  def best_match_for(source_base_dir)
42
46
  keys.
43
47
  select { |pathname| source_base_dir.to_s.match(/#{Regexp.escape(pathname.to_s)}/) }.
@@ -3,11 +3,12 @@ require_relative './configuration_validator'
3
3
  module Reek
4
4
  module Configuration
5
5
  #
6
- # Hash extension for excluded paths.
6
+ # Array extension for excluded paths.
7
7
  #
8
8
  module ExcludedPaths
9
9
  include ConfigurationValidator
10
10
 
11
+ # :reek:NestedIterators: { max_allowed_nesting: 2 }
11
12
  def add(paths)
12
13
  paths.each do |path|
13
14
  with_valid_directory(path) { |directory| self << directory }
@@ -2,7 +2,6 @@ require_relative '../code_comment'
2
2
  require_relative '../ast/object_refs'
3
3
 
4
4
  module Reek
5
- # @api private
6
5
  module Context
7
6
  #
8
7
  # Superclass for all types of source code context. Each instance represents
@@ -10,7 +9,8 @@ module Reek
10
9
  # code element. CodeContexts form a tree in the same way the code does,
11
10
  # with each context holding a reference to a unique outer context.
12
11
  #
13
- # @api private
12
+ # :reek:TooManyMethods: { max_methods: 19 }
13
+ # :reek:TooManyInstanceVariables: { max_instance_variables: 8 }
14
14
  class CodeContext
15
15
  attr_reader :exp
16
16
  attr_reader :num_statements
@@ -77,16 +77,19 @@ module Reek
77
77
  self.num_statements += num
78
78
  end
79
79
 
80
+ # :reek:TooManyStatements: { max_statements: 6 }
81
+ # :reek:FeatureEnvy
80
82
  def record_call_to(exp)
81
83
  receiver = exp.receiver
82
84
  type = receiver ? receiver.type : :self
85
+ line = exp.line
83
86
  case type
84
87
  when :lvar, :lvasgn
85
88
  unless exp.object_creation_call?
86
- refs.record_reference_to(receiver.name, line: exp.line)
89
+ refs.record_reference_to(receiver.name, line: line)
87
90
  end
88
91
  when :self
89
- refs.record_reference_to(:self, line: exp.line)
92
+ refs.record_reference_to(:self, line: line)
90
93
  end
91
94
  end
92
95
 
@@ -159,6 +162,10 @@ module Reek
159
162
  end
160
163
  end
161
164
 
165
+ def non_public_visibility?
166
+ visibility != :public
167
+ end
168
+
162
169
  protected
163
170
 
164
171
  attr_writer :num_statements, :visibility