reek 4.4.2 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +52 -23
- data/README.md +16 -3
- data/ataru_setup.rb +1 -1
- data/docs/API.md +1 -4
- data/docs/How-reek-works-internally.md +5 -5
- data/docs/Style-Guide.md +7 -0
- data/features/command_line_interface/options.feature +1 -0
- data/features/command_line_interface/show_progress.feature +33 -0
- data/features/configuration_files/masking_smells.feature +0 -1
- data/features/configuration_via_source_comments/erroneous_source_comments.feature +18 -4
- data/features/configuration_via_source_comments/well_formed_source_comments.feature +116 -0
- data/features/step_definitions/sample_file_steps.rb +5 -0
- data/features/todo_list.feature +42 -14
- data/lib/reek.rb +1 -1
- data/lib/reek/cli/application.rb +5 -0
- data/lib/reek/cli/command/report_command.rb +6 -1
- data/lib/reek/cli/command/todo_list_command.rb +1 -2
- data/lib/reek/cli/options.rb +19 -3
- data/lib/reek/code_comment.rb +83 -11
- data/lib/reek/configuration/configuration_validator.rb +2 -2
- data/lib/reek/errors/bad_detector_in_comment_error.rb +35 -0
- data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +34 -0
- data/lib/reek/examiner.rb +36 -14
- data/lib/reek/report.rb +28 -9
- data/lib/reek/report/base_report.rb +77 -0
- data/lib/reek/report/code_climate.rb +4 -0
- data/lib/reek/report/code_climate/code_climate_fingerprint.rb +48 -0
- data/lib/reek/report/code_climate/code_climate_formatter.rb +5 -0
- data/lib/reek/report/code_climate/code_climate_report.rb +19 -0
- data/lib/reek/report/formatter.rb +5 -56
- data/lib/reek/report/{heading_formatter.rb → formatter/heading_formatter.rb} +4 -4
- data/lib/reek/report/formatter/location_formatter.rb +41 -0
- data/lib/reek/report/formatter/progress_formatter.rb +80 -0
- data/lib/reek/report/formatter/simple_warning_formatter.rb +35 -0
- data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +35 -0
- data/lib/reek/report/html_report.rb +21 -0
- data/lib/reek/report/{html_report.html.erb → html_report/html_report.html.erb} +0 -0
- data/lib/reek/report/json_report.rb +18 -0
- data/lib/reek/report/text_report.rb +68 -0
- data/lib/reek/report/xml_report.rb +61 -0
- data/lib/reek/report/yaml_report.rb +18 -0
- data/lib/reek/smell_detectors.rb +30 -0
- data/lib/reek/{smells → smell_detectors}/attribute.rb +3 -3
- data/lib/reek/{smells/smell_detector.rb → smell_detectors/base_detector.rb} +3 -3
- data/lib/reek/{smells → smell_detectors}/boolean_parameter.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/class_variable.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/control_parameter.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/data_clump.rb +3 -3
- data/lib/reek/{smells/smell_repository.rb → smell_detectors/detector_repository.rb} +9 -9
- data/lib/reek/{smells → smell_detectors}/duplicate_method_call.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/feature_envy.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/instance_variable_assumption.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/irresponsible_module.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/long_parameter_list.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/long_yield_list.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/manual_dispatch.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/module_initialize.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/nested_iterators.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/nil_check.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/prima_donna_method.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/repeated_conditional.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/smell_configuration.rb +1 -1
- data/lib/reek/{smells → smell_detectors}/smell_warning.rb +1 -1
- data/lib/reek/{smells → smell_detectors}/subclassed_from_core_class.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_constants.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_instance_variables.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_methods.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_statements.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_method_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_module_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_parameter_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_variable_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/unused_parameters.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/unused_private_method.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/utility_function.rb +3 -3
- data/lib/reek/spec/should_reek_of.rb +1 -1
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +1 -1
- data/spec/factories/factories.rb +6 -6
- data/spec/reek/cli/command/report_command_spec.rb +3 -1
- data/spec/reek/cli/options_spec.rb +12 -2
- data/spec/reek/code_comment_spec.rb +18 -6
- data/spec/reek/configuration/app_configuration_spec.rb +12 -12
- data/spec/reek/configuration/default_directive_spec.rb +1 -1
- data/spec/reek/configuration/directory_directives_spec.rb +2 -2
- data/spec/reek/examiner_spec.rb +56 -28
- data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +122 -0
- data/spec/reek/report/{code_climate_formatter_spec.rb → code_climate/code_climate_formatter_spec.rb} +6 -2
- data/spec/reek/report/{code_climate_report_spec.rb → code_climate/code_climate_report_spec.rb} +7 -5
- data/spec/reek/report/{location_formatter_spec.rb → formatter/location_formatter_spec.rb} +4 -4
- data/spec/reek/report/formatter/progress_formatter_spec.rb +68 -0
- data/spec/reek/report/html_report_spec.rb +1 -1
- data/spec/reek/report/json_report_spec.rb +2 -2
- data/spec/reek/report/text_report_spec.rb +3 -4
- data/spec/reek/report/xml_report_spec.rb +1 -1
- data/spec/reek/report/yaml_report_spec.rb +2 -2
- data/spec/reek/report_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/attribute_spec.rb +2 -2
- data/spec/reek/{smells/smell_detector_spec.rb → smell_detectors/base_detector_spec.rb} +5 -5
- data/spec/reek/{smells → smell_detectors}/boolean_parameter_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/class_variable_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/control_parameter_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/data_clump_spec.rb +2 -2
- data/spec/reek/smell_detectors/detector_repository_spec.rb +22 -0
- data/spec/reek/{smells → smell_detectors}/duplicate_method_call_spec.rb +6 -6
- data/spec/reek/{smells → smell_detectors}/feature_envy_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/instance_variable_assumption_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/irresponsible_module_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/long_parameter_list_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/long_yield_list_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/manual_dispatch_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/module_initialize_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/nested_iterators_spec.rb +4 -4
- data/spec/reek/{smells → smell_detectors}/nil_check_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/prima_donna_method_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/repeated_conditional_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/smell_configuration_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/smell_warning_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/subclassed_from_core_class_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/too_many_constants_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/too_many_instance_variables_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/too_many_methods_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/too_many_statements_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/uncommunicative_method_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/uncommunicative_module_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/uncommunicative_parameter_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/uncommunicative_variable_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/unused_parameters_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/unused_private_method_spec.rb +4 -4
- data/spec/reek/{smells → smell_detectors}/utility_function_spec.rb +3 -3
- data/spec/reek/spec/should_reek_of_spec.rb +3 -3
- data/tasks/configuration.rake +2 -2
- metadata +95 -81
- data/features/smells/subclassed_from_core_class.feature +0 -14
- data/features/smells/too_many_constants.feature +0 -19
- data/lib/reek/errors.rb +0 -32
- data/lib/reek/report/location_formatter.rb +0 -39
- data/lib/reek/report/report.rb +0 -229
- data/lib/reek/smells.rb +0 -30
- data/spec/reek/smells/smell_repository_spec.rb +0 -22
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Reek
|
4
|
+
module Report
|
5
|
+
module Formatter
|
6
|
+
#
|
7
|
+
# Basic formatter that just shows a simple message for each warning,
|
8
|
+
# prepended with the result of the passed-in location formatter.
|
9
|
+
#
|
10
|
+
class SimpleWarningFormatter
|
11
|
+
def initialize(location_formatter: BlankLocationFormatter)
|
12
|
+
@location_formatter = location_formatter
|
13
|
+
end
|
14
|
+
|
15
|
+
def format(warning)
|
16
|
+
"#{location_formatter.format(warning)}#{warning.base_message}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# :reek:UtilityFunction
|
20
|
+
def format_hash(warning)
|
21
|
+
warning.yaml_hash
|
22
|
+
end
|
23
|
+
|
24
|
+
# :reek:UtilityFunction
|
25
|
+
def format_code_climate_hash(warning)
|
26
|
+
CodeClimateFormatter.new(warning).render
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :location_formatter
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'simple_warning_formatter'
|
3
|
+
|
4
|
+
module Reek
|
5
|
+
module Report
|
6
|
+
module Formatter
|
7
|
+
#
|
8
|
+
# Formatter that adds a link to the wiki to the basic message from
|
9
|
+
# SimpleWarningFormatter.
|
10
|
+
#
|
11
|
+
class WikiLinkWarningFormatter < SimpleWarningFormatter
|
12
|
+
BASE_URL_FOR_HELP_LINK = 'https://github.com/troessner/reek/blob/master/docs/'.freeze
|
13
|
+
|
14
|
+
def format(warning)
|
15
|
+
"#{super} [#{explanatory_link(warning)}]"
|
16
|
+
end
|
17
|
+
|
18
|
+
def format_hash(warning)
|
19
|
+
super.merge('wiki_link' => explanatory_link(warning))
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def explanatory_link(warning)
|
25
|
+
"#{BASE_URL_FOR_HELP_LINK}#{class_name_to_param(warning.smell_type)}.md"
|
26
|
+
end
|
27
|
+
|
28
|
+
# :reek:UtilityFunction
|
29
|
+
def class_name_to_param(name)
|
30
|
+
name.split(/(?=[A-Z])/).join('-')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'base_report'
|
3
|
+
|
4
|
+
module Reek
|
5
|
+
module Report
|
6
|
+
#
|
7
|
+
# Saves the report as a HTML file
|
8
|
+
#
|
9
|
+
# @public
|
10
|
+
#
|
11
|
+
class HTMLReport < BaseReport
|
12
|
+
require 'erb'
|
13
|
+
|
14
|
+
# @public
|
15
|
+
def show
|
16
|
+
template_path = Pathname.new("#{__dir__}/html_report/html_report.html.erb")
|
17
|
+
puts ERB.new(template_path.read).result(binding)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'base_report'
|
3
|
+
|
4
|
+
module Reek
|
5
|
+
module Report
|
6
|
+
#
|
7
|
+
# Displays a list of smells in JSON format
|
8
|
+
# JSON with empty array for 0 smells
|
9
|
+
#
|
10
|
+
# @public
|
11
|
+
#
|
12
|
+
class JSONReport < BaseReport
|
13
|
+
def show(out = $stdout)
|
14
|
+
out.print ::JSON.generate smells.map { |smell| warning_formatter.format_hash(smell) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'base_report'
|
3
|
+
|
4
|
+
module Reek
|
5
|
+
module Report
|
6
|
+
#
|
7
|
+
# Generates a sorted, text summary of smells in examiners
|
8
|
+
#
|
9
|
+
# @public
|
10
|
+
#
|
11
|
+
class TextReport < BaseReport
|
12
|
+
# @public
|
13
|
+
def initialize(*args)
|
14
|
+
super(*args)
|
15
|
+
|
16
|
+
print progress_formatter.header
|
17
|
+
end
|
18
|
+
|
19
|
+
# @public
|
20
|
+
def add_examiner(examiner)
|
21
|
+
print progress_formatter.progress examiner
|
22
|
+
super(examiner)
|
23
|
+
end
|
24
|
+
|
25
|
+
# @public
|
26
|
+
def show
|
27
|
+
sort_examiners if smells?
|
28
|
+
print progress_formatter.footer
|
29
|
+
display_summary
|
30
|
+
display_total_smell_count
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def smell_summaries
|
36
|
+
examiners.map { |ex| summarize_single_examiner(ex) }.reject(&:empty?)
|
37
|
+
end
|
38
|
+
|
39
|
+
def display_summary
|
40
|
+
smell_summaries.each { |smell| puts smell }
|
41
|
+
end
|
42
|
+
|
43
|
+
def display_total_smell_count
|
44
|
+
return unless examiners.size > 1
|
45
|
+
print total_smell_count_message
|
46
|
+
end
|
47
|
+
|
48
|
+
def summarize_single_examiner(examiner)
|
49
|
+
result = heading_formatter.header(examiner)
|
50
|
+
if examiner.smelly?
|
51
|
+
formatted_list = report_formatter.format_list(examiner.smells,
|
52
|
+
formatter: warning_formatter)
|
53
|
+
result += ":\n#{formatted_list}"
|
54
|
+
end
|
55
|
+
result
|
56
|
+
end
|
57
|
+
|
58
|
+
def sort_examiners
|
59
|
+
examiners.sort_by!(&:smells_count).reverse! if sort_by_issue_count
|
60
|
+
end
|
61
|
+
|
62
|
+
def total_smell_count_message
|
63
|
+
colour = smells? ? WARNINGS_COLOR : NO_WARNINGS_COLOR
|
64
|
+
Rainbow("#{total_smell_count} total warning#{total_smell_count == 1 ? '' : 's'}\n").color(colour)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'base_report'
|
3
|
+
|
4
|
+
module Reek
|
5
|
+
module Report
|
6
|
+
#
|
7
|
+
# Generates a list of smells in XML format
|
8
|
+
#
|
9
|
+
# @public
|
10
|
+
#
|
11
|
+
class XMLReport < BaseReport
|
12
|
+
require 'rexml/document'
|
13
|
+
|
14
|
+
# @public
|
15
|
+
def show
|
16
|
+
document.write output: $stdout, indent: 2
|
17
|
+
$stdout.puts
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def document
|
23
|
+
REXML::Document.new.tap do |document|
|
24
|
+
document << REXML::XMLDecl.new << checkstyle
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def checkstyle
|
29
|
+
REXML::Element.new('checkstyle').tap do |checkstyle|
|
30
|
+
smells.group_by(&:source).each do |source, source_smells|
|
31
|
+
checkstyle << file(source, source_smells)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# :reek:FeatureEnvy
|
37
|
+
# :reek:NestedIterators: { max_allowed_nesting: 2 }
|
38
|
+
def file(name, smells)
|
39
|
+
REXML::Element.new('file').tap do |file|
|
40
|
+
file.add_attribute 'name', File.realpath(name)
|
41
|
+
smells.each do |smell|
|
42
|
+
smell.lines.each do |line|
|
43
|
+
file << error(smell, line)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# :reek:UtilityFunction
|
50
|
+
def error(smell, line)
|
51
|
+
REXML::Element.new('error').tap do |error|
|
52
|
+
error.add_attributes 'column' => 0,
|
53
|
+
'line' => line,
|
54
|
+
'message' => smell.message,
|
55
|
+
'severity' => 'warning',
|
56
|
+
'source' => smell.smell_type
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'base_report'
|
3
|
+
|
4
|
+
module Reek
|
5
|
+
module Report
|
6
|
+
#
|
7
|
+
# Displays a list of smells in YAML format
|
8
|
+
# YAML with empty array for 0 smells
|
9
|
+
#
|
10
|
+
# @public
|
11
|
+
#
|
12
|
+
class YAMLReport < BaseReport
|
13
|
+
def show(out = $stdout)
|
14
|
+
out.print smells.map { |smell| warning_formatter.format_hash(smell) }.to_yaml
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'smell_detectors/attribute'
|
3
|
+
require_relative 'smell_detectors/boolean_parameter'
|
4
|
+
require_relative 'smell_detectors/class_variable'
|
5
|
+
require_relative 'smell_detectors/control_parameter'
|
6
|
+
require_relative 'smell_detectors/data_clump'
|
7
|
+
require_relative 'smell_detectors/duplicate_method_call'
|
8
|
+
require_relative 'smell_detectors/feature_envy'
|
9
|
+
require_relative 'smell_detectors/irresponsible_module'
|
10
|
+
require_relative 'smell_detectors/instance_variable_assumption'
|
11
|
+
require_relative 'smell_detectors/long_parameter_list'
|
12
|
+
require_relative 'smell_detectors/long_yield_list'
|
13
|
+
require_relative 'smell_detectors/manual_dispatch'
|
14
|
+
require_relative 'smell_detectors/module_initialize'
|
15
|
+
require_relative 'smell_detectors/nested_iterators'
|
16
|
+
require_relative 'smell_detectors/nil_check'
|
17
|
+
require_relative 'smell_detectors/prima_donna_method'
|
18
|
+
require_relative 'smell_detectors/repeated_conditional'
|
19
|
+
require_relative 'smell_detectors/subclassed_from_core_class'
|
20
|
+
require_relative 'smell_detectors/too_many_instance_variables'
|
21
|
+
require_relative 'smell_detectors/too_many_constants'
|
22
|
+
require_relative 'smell_detectors/too_many_methods'
|
23
|
+
require_relative 'smell_detectors/too_many_statements'
|
24
|
+
require_relative 'smell_detectors/uncommunicative_method_name'
|
25
|
+
require_relative 'smell_detectors/uncommunicative_module_name'
|
26
|
+
require_relative 'smell_detectors/uncommunicative_parameter_name'
|
27
|
+
require_relative 'smell_detectors/uncommunicative_variable_name'
|
28
|
+
require_relative 'smell_detectors/unused_parameters'
|
29
|
+
require_relative 'smell_detectors/unused_private_method'
|
30
|
+
require_relative 'smell_detectors/utility_function'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require_relative 'smell_configuration'
|
3
|
-
require_relative '
|
3
|
+
require_relative 'base_detector'
|
4
4
|
require_relative 'smell_warning'
|
5
5
|
|
6
6
|
module Reek
|
7
|
-
module
|
7
|
+
module SmellDetectors
|
8
8
|
#
|
9
9
|
# A class that publishes a getter or setter for an instance variable
|
10
10
|
# invites client classes to become too intimate with its inner workings,
|
@@ -16,7 +16,7 @@ module Reek
|
|
16
16
|
# See {file:docs/Attribute.md} for details.
|
17
17
|
#
|
18
18
|
# TODO: Catch attributes declared "by hand"
|
19
|
-
class Attribute <
|
19
|
+
class Attribute < BaseDetector
|
20
20
|
def initialize(*args)
|
21
21
|
super
|
22
22
|
end
|
@@ -3,7 +3,7 @@ require 'set'
|
|
3
3
|
require_relative 'smell_configuration'
|
4
4
|
|
5
5
|
module Reek
|
6
|
-
module
|
6
|
+
module SmellDetectors
|
7
7
|
#
|
8
8
|
# Shared responsibilities of all smell detectors.
|
9
9
|
#
|
@@ -14,7 +14,7 @@ module Reek
|
|
14
14
|
# for details.
|
15
15
|
#
|
16
16
|
# :reek:UnusedPrivateMethod: { exclude: [ smell_warning ] }
|
17
|
-
class
|
17
|
+
class BaseDetector
|
18
18
|
attr_reader :config
|
19
19
|
# The name of the config field that lists the names of code contexts
|
20
20
|
# that should not be checked. Add this field to the config for each
|
@@ -102,7 +102,7 @@ module Reek
|
|
102
102
|
end
|
103
103
|
|
104
104
|
#
|
105
|
-
# Returns all descendants of
|
105
|
+
# Returns all descendants of BaseDetector
|
106
106
|
#
|
107
107
|
# @return [Array<Constant>], e.g.:
|
108
108
|
# [Reek::Smells::Attribute,
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require_relative '
|
2
|
+
require_relative 'base_detector'
|
3
3
|
require_relative 'smell_warning'
|
4
4
|
|
5
5
|
module Reek
|
6
|
-
module
|
6
|
+
module SmellDetectors
|
7
7
|
#
|
8
8
|
# A Boolean parameter effectively permits a method's caller
|
9
9
|
# to decide which execution path to take. The
|
@@ -13,7 +13,7 @@ module Reek
|
|
13
13
|
# default initializer.
|
14
14
|
#
|
15
15
|
# See {file:docs/Boolean-Parameter.md} for details.
|
16
|
-
class BooleanParameter <
|
16
|
+
class BooleanParameter < BaseDetector
|
17
17
|
#
|
18
18
|
# Checks whether the given method has any Boolean parameters.
|
19
19
|
#
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'set'
|
3
|
-
require_relative '
|
3
|
+
require_relative 'base_detector'
|
4
4
|
require_relative 'smell_warning'
|
5
5
|
|
6
6
|
module Reek
|
7
|
-
module
|
7
|
+
module SmellDetectors
|
8
8
|
#
|
9
9
|
# Class variables form part of the global runtime state, and as such make
|
10
10
|
# it easy for one part of the system to accidentally or inadvertently
|
@@ -14,7 +14,7 @@ module Reek
|
|
14
14
|
# the context of the test includes all global state).
|
15
15
|
#
|
16
16
|
# See {file:docs/Class-Variable.md} for details.
|
17
|
-
class ClassVariable <
|
17
|
+
class ClassVariable < BaseDetector
|
18
18
|
def self.contexts # :nodoc:
|
19
19
|
[:class, :module]
|
20
20
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require_relative '
|
2
|
+
require_relative 'base_detector'
|
3
3
|
require_relative 'smell_warning'
|
4
4
|
|
5
5
|
module Reek
|
6
|
-
module
|
6
|
+
module SmellDetectors
|
7
7
|
#
|
8
8
|
# Control Coupling occurs when a method or block checks the value of
|
9
9
|
# a parameter in order to decide which execution path to take. The
|
@@ -42,7 +42,7 @@ module Reek
|
|
42
42
|
# the source code.
|
43
43
|
#
|
44
44
|
# See {file:docs/Control-Parameter.md} for details.
|
45
|
-
class ControlParameter <
|
45
|
+
class ControlParameter < BaseDetector
|
46
46
|
#
|
47
47
|
# Checks whether the given method chooses its execution path
|
48
48
|
# by testing the value of one of its parameters.
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require_relative '
|
2
|
+
require_relative 'base_detector'
|
3
3
|
require_relative 'smell_warning'
|
4
4
|
|
5
5
|
module Reek
|
6
|
-
module
|
6
|
+
module SmellDetectors
|
7
7
|
#
|
8
8
|
# A Data Clump occurs when the same two or three items frequently
|
9
9
|
# appear together in classes and parameter lists, or when a group
|
@@ -17,7 +17,7 @@ module Reek
|
|
17
17
|
# the same names that are expected by three or more methods of a class.
|
18
18
|
#
|
19
19
|
# See {file:docs/Data-Clump.md} for details.
|
20
|
-
class DataClump <
|
20
|
+
class DataClump < BaseDetector
|
21
21
|
#
|
22
22
|
# The name of the config field that sets the maximum allowed
|
23
23
|
# copies of any clump. No group of common parameters will be
|
@@ -1,28 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require_relative '../
|
3
|
-
require_relative '
|
2
|
+
require_relative '../smell_detectors'
|
3
|
+
require_relative 'base_detector'
|
4
4
|
require_relative '../configuration/app_configuration'
|
5
5
|
|
6
6
|
module Reek
|
7
|
-
module
|
7
|
+
module SmellDetectors
|
8
8
|
#
|
9
|
-
# Contains all the existing
|
9
|
+
# Contains all the existing smell detectors and exposes operations on them.
|
10
10
|
#
|
11
|
-
class
|
12
|
-
# @return [Array<Reek::
|
11
|
+
class DetectorRepository
|
12
|
+
# @return [Array<Reek::SmellDetectors::BaseDetector>] All known SmellDetectors
|
13
13
|
# e.g. [Reek::Smells::BooleanParameter, Reek::Smells::ClassVariable].
|
14
14
|
def self.smell_types
|
15
|
-
Reek::
|
15
|
+
Reek::SmellDetectors::BaseDetector.descendants.sort_by(&:name)
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param filter_by_smells [Array<String>]
|
19
19
|
# List of smell types to filter by, e.g. "DuplicateMethodCall".
|
20
|
-
# More precisely it should be whatever is returned by `
|
20
|
+
# More precisely it should be whatever is returned by `BaseDetector`.smell_type.
|
21
21
|
# This means that you can write the "DuplicateMethodCall" from above also like this:
|
22
22
|
# Reek::Smells::DuplicateMethodCall.smell_type
|
23
23
|
# if you want to make sure you do not fat-finger strings.
|
24
24
|
#
|
25
|
-
# @return [Array<Reek::
|
25
|
+
# @return [Array<Reek::SmellDetectors::BaseDetector>] All SmellDetectors that we want to filter for
|
26
26
|
# e.g. [Reek::Smells::Attribute].
|
27
27
|
def self.eligible_smell_types(filter_by_smells = [])
|
28
28
|
return smell_types if filter_by_smells.empty?
|