reek 4.8.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/{samples/configuration/more_than_one_configuration_file/regular.reek → .reek.yml} +0 -0
- data/.rubocop.yml +17 -3
- data/.simplecov +1 -0
- data/.travis.yml +0 -5
- data/.yardopts +1 -1
- data/CHANGELOG.md +28 -0
- data/Gemfile +1 -1
- data/README.md +113 -98
- data/Rakefile +16 -3
- data/bin/reek +1 -3
- data/docs/API.md +2 -9
- data/docs/Basic-Smell-Options.md +51 -11
- data/docs/Code-Smells.md +1 -1
- data/docs/Command-Line-Options.md +14 -4
- data/docs/Duplicate-Method-Call.md +49 -1
- data/docs/Feature-Envy.md +44 -0
- data/docs/How-To-Write-New-Detectors.md +2 -3
- data/docs/{Prima-Donna-Method.md → Missing-Safe-Method.md} +11 -9
- data/docs/Rake-Task.md +1 -1
- data/docs/Reek-4-to-Reek-5-migration.md +193 -0
- data/docs/Reek-Driven-Development.md +1 -1
- data/docs/Uncommunicative-Method-Name.md +43 -4
- data/docs/Uncommunicative-Module-Name.md +48 -6
- data/docs/Uncommunicative-Parameter-Name.md +42 -4
- data/docs/Uncommunicative-Variable-Name.md +73 -2
- data/docs/Unused-Private-Method.md +1 -1
- data/docs/defaults.reek.yml +129 -0
- data/docs/yard_plugin.rb +1 -0
- data/features/command_line_interface/options.feature +46 -4
- data/features/command_line_interface/stdin.feature +27 -5
- data/features/configuration_files/accept_setting.feature +39 -22
- data/features/configuration_files/directory_specific_directives.feature +58 -53
- data/features/configuration_files/exclude_directives.feature +8 -7
- data/features/configuration_files/masking_smells.feature +35 -6
- data/features/configuration_files/mix_accept_reject_setting.feature +24 -21
- data/features/configuration_files/reject_setting.feature +45 -34
- data/features/configuration_files/schema_validation.feature +59 -0
- data/features/configuration_files/unused_private_method.feature +14 -12
- data/features/configuration_loading.feature +50 -7
- data/features/rake_task/rake_task.feature +5 -5
- data/features/reports/json.feature +4 -1
- data/features/reports/reports.feature +12 -12
- data/features/reports/yaml.feature +3 -0
- data/features/rspec_matcher.feature +9 -1
- data/features/step_definitions/reek_steps.rb +4 -0
- data/features/step_definitions/sample_file_steps.rb +9 -4
- data/features/support/env.rb +2 -2
- data/features/todo_list.feature +16 -13
- data/lib/reek/ast/node.rb +3 -6
- data/lib/reek/ast/object_refs.rb +1 -1
- data/lib/reek/ast/sexp_extensions/if.rb +1 -1
- data/lib/reek/ast/sexp_extensions/methods.rb +1 -1
- data/lib/reek/cli/application.rb +4 -3
- data/lib/reek/cli/command/report_command.rb +1 -2
- data/lib/reek/cli/command/todo_list_command.rb +4 -2
- data/lib/reek/cli/options.rb +27 -13
- data/lib/reek/cli/silencer.rb +14 -3
- data/lib/reek/code_comment.rb +14 -16
- data/lib/reek/configuration/app_configuration.rb +32 -28
- data/lib/reek/configuration/configuration_converter.rb +110 -0
- data/lib/reek/configuration/configuration_file_finder.rb +15 -40
- data/lib/reek/configuration/configuration_validator.rb +12 -23
- data/lib/reek/configuration/default_directive.rb +17 -3
- data/lib/reek/configuration/directory_directives.rb +17 -11
- data/lib/reek/configuration/excluded_paths.rb +1 -1
- data/lib/reek/configuration/rake_task_converter.rb +29 -0
- data/lib/reek/configuration/schema.yml +210 -0
- data/lib/reek/configuration/schema_validator.rb +38 -0
- data/lib/reek/context/attribute_context.rb +1 -1
- data/lib/reek/context/code_context.rb +4 -4
- data/lib/reek/context/method_context.rb +2 -2
- data/lib/reek/context/module_context.rb +1 -1
- data/lib/reek/context_builder.rb +9 -9
- data/lib/reek/detector_repository.rb +6 -0
- data/lib/reek/documentation_link.rb +2 -2
- data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +1 -1
- data/lib/reek/errors/bad_detector_in_comment_error.rb +1 -1
- data/lib/reek/errors/config_file_error.rb +11 -0
- data/lib/reek/errors/encoding_error.rb +2 -2
- data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +1 -1
- data/lib/reek/errors/incomprehensible_source_error.rb +2 -2
- data/lib/reek/errors/syntax_error.rb +41 -0
- data/lib/reek/examiner.rb +9 -19
- data/lib/reek/rake/task.rb +3 -3
- data/lib/reek/report.rb +15 -10
- data/lib/reek/report/base_report.rb +8 -12
- data/lib/reek/report/code_climate/code_climate_configuration.yml +5 -9
- data/lib/reek/report/documentation_link_warning_formatter.rb +17 -0
- data/lib/reek/report/heading_formatter.rb +54 -0
- data/lib/reek/report/json_report.rb +1 -1
- data/lib/reek/report/location_formatter.rb +40 -0
- data/lib/reek/report/progress_formatter.rb +79 -0
- data/lib/reek/report/simple_warning_formatter.rb +34 -0
- data/lib/reek/report/text_report.rb +1 -2
- data/lib/reek/report/xml_report.rb +3 -3
- data/lib/reek/report/yaml_report.rb +1 -1
- data/lib/reek/smell_configuration.rb +2 -2
- data/lib/reek/smell_detectors.rb +1 -2
- data/lib/reek/smell_detectors/attribute.rb +0 -1
- data/lib/reek/smell_detectors/base_detector.rb +8 -11
- data/lib/reek/smell_detectors/boolean_parameter.rb +0 -1
- data/lib/reek/smell_detectors/class_variable.rb +0 -1
- data/lib/reek/smell_detectors/control_parameter.rb +17 -32
- data/lib/reek/smell_detectors/data_clump.rb +3 -4
- data/lib/reek/smell_detectors/duplicate_method_call.rb +5 -6
- data/lib/reek/smell_detectors/feature_envy.rb +0 -1
- data/lib/reek/smell_detectors/instance_variable_assumption.rb +0 -1
- data/lib/reek/smell_detectors/irresponsible_module.rb +0 -1
- data/lib/reek/smell_detectors/long_parameter_list.rb +1 -2
- data/lib/reek/smell_detectors/long_yield_list.rb +2 -3
- data/lib/reek/smell_detectors/manual_dispatch.rb +2 -2
- data/lib/reek/smell_detectors/{prima_donna_method.rb → missing_safe_method.rb} +6 -7
- data/lib/reek/smell_detectors/module_initialize.rb +0 -1
- data/lib/reek/smell_detectors/nested_iterators.rb +4 -5
- data/lib/reek/smell_detectors/nil_check.rb +0 -1
- data/lib/reek/smell_detectors/repeated_conditional.rb +3 -4
- data/lib/reek/smell_detectors/subclassed_from_core_class.rb +0 -1
- data/lib/reek/smell_detectors/too_many_constants.rb +1 -2
- data/lib/reek/smell_detectors/too_many_instance_variables.rb +1 -2
- data/lib/reek/smell_detectors/too_many_methods.rb +1 -2
- data/lib/reek/smell_detectors/too_many_statements.rb +1 -2
- data/lib/reek/smell_detectors/uncommunicative_method_name.rb +2 -3
- data/lib/reek/smell_detectors/uncommunicative_module_name.rb +2 -3
- data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +2 -3
- data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +4 -5
- data/lib/reek/smell_detectors/unused_parameters.rb +0 -1
- data/lib/reek/smell_detectors/unused_private_method.rb +0 -1
- data/lib/reek/smell_detectors/utility_function.rb +1 -2
- data/lib/reek/smell_warning.rb +10 -8
- data/lib/reek/source/source_code.rb +40 -55
- data/lib/reek/source/source_locator.rb +7 -7
- data/lib/reek/spec.rb +6 -6
- data/lib/reek/spec/should_reek.rb +2 -2
- data/lib/reek/spec/should_reek_of.rb +9 -16
- data/lib/reek/spec/should_reek_only_of.rb +4 -4
- data/lib/reek/tree_dresser.rb +5 -5
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +3 -3
- data/samples/checkstyle.xml +1 -1
- data/samples/{clean.rb → clean_source/clean.rb} +0 -0
- data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +29 -0
- data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +30 -0
- data/samples/configuration/full_configuration.reek +8 -4
- data/samples/configuration/full_mask.reek +5 -4
- data/samples/{exceptions.reek → configuration/home/home.reek.yml} +0 -0
- data/samples/configuration/partial_mask.reek +3 -2
- data/samples/configuration/regular_configuration/.reek.yml +4 -0
- data/samples/configuration/{more_than_one_configuration_file/todo.reek → regular_configuration/empty_sub_directory/.gitignore} +0 -0
- data/samples/{configuration/single_configuration_file/.reek → no_config_file/.keep} +0 -0
- data/samples/paths.rb +5 -4
- data/samples/{inline.rb → smelly_source/inline.rb} +0 -0
- data/samples/{optparse.rb → smelly_source/optparse.rb} +0 -0
- data/samples/{redcloth.rb → smelly_source/redcloth.rb} +0 -0
- data/samples/{smelly.rb → smelly_source/smelly.rb} +0 -0
- data/samples/source_with_hidden_directories/.hidden/hidden.rb +1 -0
- data/samples/source_with_hidden_directories/not_hidden.rb +1 -0
- data/samples/{source_with_hidden_directories/uncommunicative_parameter_name.rb → source_with_non_ruby_files/ruby.rb} +0 -0
- data/spec/reek/ast/node_spec.rb +5 -5
- data/spec/reek/cli/application_spec.rb +18 -4
- data/spec/reek/cli/command/todo_list_command_spec.rb +4 -2
- data/spec/reek/cli/silencer_spec.rb +28 -0
- data/spec/reek/code_comment_spec.rb +0 -7
- data/spec/reek/configuration/app_configuration_spec.rb +44 -31
- data/spec/reek/configuration/configuration_file_finder_spec.rb +133 -49
- data/spec/reek/configuration/default_directive_spec.rb +1 -1
- data/spec/reek/configuration/directory_directives_spec.rb +3 -4
- data/spec/reek/configuration/excluded_paths_spec.rb +5 -5
- data/spec/reek/configuration/rake_task_converter_spec.rb +33 -0
- data/spec/reek/configuration/schema_validator_spec.rb +165 -0
- data/spec/reek/context/code_context_spec.rb +1 -1
- data/spec/reek/examiner_spec.rb +28 -1
- data/spec/reek/report/json_report_spec.rb +13 -46
- data/spec/reek/report/{formatter/location_formatter_spec.rb → location_formatter_spec.rb} +5 -5
- data/spec/reek/report/{formatter/progress_formatter_spec.rb → progress_formatter_spec.rb} +4 -4
- data/spec/reek/report/text_report_spec.rb +4 -4
- data/spec/reek/report/xml_report_spec.rb +1 -1
- data/spec/reek/report/yaml_report_spec.rb +9 -38
- data/spec/reek/report_spec.rb +3 -3
- data/spec/reek/smell_detectors/feature_envy_spec.rb +2 -2
- data/spec/reek/smell_detectors/{prima_donna_method_spec.rb → missing_safe_method_spec.rb} +9 -9
- data/spec/reek/smell_detectors/too_many_constants_spec.rb +3 -3
- data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +1 -1
- data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +6 -6
- data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +6 -4
- data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +6 -4
- data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +6 -6
- data/spec/reek/smell_detectors/unused_private_method_spec.rb +1 -1
- data/spec/reek/smell_warning_spec.rb +4 -0
- data/spec/reek/source/source_code_spec.rb +16 -22
- data/spec/reek/source/source_locator_spec.rb +11 -11
- data/spec/reek/spec/should_reek_of_spec.rb +0 -4
- data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
- data/spec/reek/spec/should_reek_spec.rb +1 -1
- data/spec/reek/tree_dresser_spec.rb +2 -6
- data/spec/spec_helper.rb +3 -5
- data/tasks/configuration.rake +8 -5
- metadata +56 -35
- data/defaults.reek +0 -131
- data/features/configuration_files/warn_about_multiple_configuration_files.feature +0 -44
- data/lib/reek/report/formatter.rb +0 -33
- data/lib/reek/report/formatter/heading_formatter.rb +0 -52
- data/lib/reek/report/formatter/location_formatter.rb +0 -42
- data/lib/reek/report/formatter/progress_formatter.rb +0 -81
- data/lib/reek/report/formatter/simple_warning_formatter.rb +0 -35
- data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +0 -23
- data/lib/reek/smell_detectors/syntax.rb +0 -37
- data/samples/configuration/non_public_modifiers_mask.reek +0 -3
- data/samples/smelly_with_inline_mask.rb +0 -8
- data/samples/smelly_with_modifiers.rb +0 -12
- data/samples/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -5
- data/samples/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -6
- data/spec/reek/smell_detectors/syntax_spec.rb +0 -17
@@ -1,44 +0,0 @@
|
|
1
|
-
Feature: Warn on multiple configuration files
|
2
|
-
Reek is designed for one configuration file and for one configuration file only.
|
3
|
-
We should make this clear to the user by warning him when we detect multiple
|
4
|
-
configuration files and then exiting the program.
|
5
|
-
|
6
|
-
Scenario: Warn on more than one configuration file
|
7
|
-
Given the smelly file 'smelly.rb'
|
8
|
-
And a file named "config.reek" with:
|
9
|
-
"""
|
10
|
-
---
|
11
|
-
UncommunicativeMethodName:
|
12
|
-
enabled: false
|
13
|
-
"""
|
14
|
-
And a file named ".todo.reek" with:
|
15
|
-
"""
|
16
|
-
---
|
17
|
-
UtilityFunction:
|
18
|
-
enabled: false
|
19
|
-
"""
|
20
|
-
When I run reek smelly.rb
|
21
|
-
Then it reports the error "Error: Found multiple configuration files '.todo.reek', 'config.reek'"
|
22
|
-
And it reports the error "Reek supports only one configuration file. You have 2 options now:"
|
23
|
-
And it reports the error "1) Remove all offending files"
|
24
|
-
And it reports the error "2) Be specific about which one you want to load via the -c switch"
|
25
|
-
And the exit status indicates an error
|
26
|
-
|
27
|
-
Scenario: Do not warn on more than one when we explicitly specify one configuration file
|
28
|
-
Given the smelly file 'smelly.rb'
|
29
|
-
And a file named "config.reek" with:
|
30
|
-
"""
|
31
|
-
---
|
32
|
-
UncommunicativeMethodName:
|
33
|
-
enabled: false
|
34
|
-
"""
|
35
|
-
And a file named ".todo.reek" with:
|
36
|
-
"""
|
37
|
-
---
|
38
|
-
UtilityFunction:
|
39
|
-
enabled: false
|
40
|
-
"""
|
41
|
-
When I run reek -c config.reek smelly.rb
|
42
|
-
Then the exit status indicates smells
|
43
|
-
And it reports no errors
|
44
|
-
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'code_climate/code_climate_formatter'
|
4
|
-
require_relative 'formatter/heading_formatter'
|
5
|
-
require_relative 'formatter/location_formatter'
|
6
|
-
require_relative 'formatter/progress_formatter'
|
7
|
-
require_relative 'formatter/simple_warning_formatter'
|
8
|
-
require_relative 'formatter/wiki_link_warning_formatter'
|
9
|
-
|
10
|
-
module Reek
|
11
|
-
module Report
|
12
|
-
#
|
13
|
-
# Formatter handling the formatting of the report at large.
|
14
|
-
# Formatting of the individual warnings is handled by the
|
15
|
-
# passed-in warning formatter.
|
16
|
-
#
|
17
|
-
module Formatter
|
18
|
-
module_function
|
19
|
-
|
20
|
-
def format_list(warnings, formatter: SimpleWarningFormatter.new)
|
21
|
-
warnings.map { |warning| " #{formatter.format(warning)}" }.join("\n")
|
22
|
-
end
|
23
|
-
|
24
|
-
def header(examiner)
|
25
|
-
count = examiner.smells_count
|
26
|
-
result = Rainbow("#{examiner.description} -- ").cyan +
|
27
|
-
Rainbow("#{count} warning").yellow
|
28
|
-
result += Rainbow('s').yellow unless count == 1
|
29
|
-
result
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Reek
|
4
|
-
module Report
|
5
|
-
module Formatter
|
6
|
-
#
|
7
|
-
# Base class for heading formatters.
|
8
|
-
# Is responsible for formatting the heading emitted for each examiner
|
9
|
-
#
|
10
|
-
# @abstract Override {#show_header?} to implement a heading formatter.
|
11
|
-
class HeadingFormatterBase
|
12
|
-
attr_reader :report_formatter
|
13
|
-
|
14
|
-
def initialize(report_formatter)
|
15
|
-
@report_formatter = report_formatter
|
16
|
-
end
|
17
|
-
|
18
|
-
# :reek:UtilityFunction
|
19
|
-
def show_header?(_examiner)
|
20
|
-
raise NotImplementedError
|
21
|
-
end
|
22
|
-
|
23
|
-
def header(examiner)
|
24
|
-
if show_header?(examiner)
|
25
|
-
report_formatter.header examiner
|
26
|
-
else
|
27
|
-
''
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Lists out each examiner, even if it has no smell
|
34
|
-
#
|
35
|
-
class VerboseHeadingFormatter < HeadingFormatterBase
|
36
|
-
def show_header?(_examiner)
|
37
|
-
true
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# Lists only smelly examiners
|
43
|
-
#
|
44
|
-
class QuietHeadingFormatter < HeadingFormatterBase
|
45
|
-
# :reek:UtilityFunction
|
46
|
-
def show_header?(examiner)
|
47
|
-
examiner.smelly?
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Reek
|
4
|
-
module Report
|
5
|
-
module Formatter
|
6
|
-
#
|
7
|
-
# Formats the location of a warning as an empty string.
|
8
|
-
#
|
9
|
-
module BlankLocationFormatter
|
10
|
-
module_function
|
11
|
-
|
12
|
-
def format(_warning)
|
13
|
-
''
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
#
|
18
|
-
# Formats the location of a warning as an array of line numbers.
|
19
|
-
#
|
20
|
-
module DefaultLocationFormatter
|
21
|
-
module_function
|
22
|
-
|
23
|
-
def format(warning)
|
24
|
-
"#{warning.lines.sort.inspect}:"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# Formats the location of a warning as a combination of source file name
|
30
|
-
# and line number. In this format, it is not possible to show more than
|
31
|
-
# one line number, so the first number is displayed.
|
32
|
-
#
|
33
|
-
module SingleLineLocationFormatter
|
34
|
-
module_function
|
35
|
-
|
36
|
-
def format(warning)
|
37
|
-
"#{warning.source}:#{warning.lines.sort.first}: "
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Reek
|
4
|
-
module Report
|
5
|
-
module Formatter
|
6
|
-
module ProgressFormatter
|
7
|
-
#
|
8
|
-
# Base class for progress formatters.
|
9
|
-
# Is responsible for formatting the progress emitted for each examiner
|
10
|
-
#
|
11
|
-
# @abstract Override {#header, #progress, #footer} to implement a progress formatter.
|
12
|
-
class Base
|
13
|
-
attr_reader :sources_count
|
14
|
-
|
15
|
-
def initialize(sources_count)
|
16
|
-
@sources_count = sources_count
|
17
|
-
end
|
18
|
-
|
19
|
-
def header
|
20
|
-
raise NotImplementedError
|
21
|
-
end
|
22
|
-
|
23
|
-
def progress(_examiner)
|
24
|
-
raise NotImplementedError
|
25
|
-
end
|
26
|
-
|
27
|
-
def footer
|
28
|
-
raise NotImplementedError
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Shows the status of each source as either a dot (.) or an S
|
34
|
-
#
|
35
|
-
class Dots < Base
|
36
|
-
NO_WARNINGS_COLOR = :green
|
37
|
-
WARNINGS_COLOR = :red
|
38
|
-
|
39
|
-
def header
|
40
|
-
"Inspecting #{sources_count} file(s):\n"
|
41
|
-
end
|
42
|
-
|
43
|
-
def progress(examiner)
|
44
|
-
examiner.smelly? ? display_smelly : display_clean
|
45
|
-
end
|
46
|
-
|
47
|
-
def footer
|
48
|
-
"\n\n"
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def display_clean
|
54
|
-
Rainbow('.').color(NO_WARNINGS_COLOR)
|
55
|
-
end
|
56
|
-
|
57
|
-
def display_smelly
|
58
|
-
Rainbow('S').color(WARNINGS_COLOR)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
#
|
63
|
-
# Does not show progress
|
64
|
-
#
|
65
|
-
class Quiet < Base
|
66
|
-
def header
|
67
|
-
''
|
68
|
-
end
|
69
|
-
|
70
|
-
def progress(_examiner)
|
71
|
-
''
|
72
|
-
end
|
73
|
-
|
74
|
-
def footer
|
75
|
-
''
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,35 +0,0 @@
|
|
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
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'simple_warning_formatter'
|
4
|
-
|
5
|
-
module Reek
|
6
|
-
module Report
|
7
|
-
module Formatter
|
8
|
-
#
|
9
|
-
# Formatter that adds a link to the wiki to the basic message from
|
10
|
-
# SimpleWarningFormatter.
|
11
|
-
#
|
12
|
-
class WikiLinkWarningFormatter < SimpleWarningFormatter
|
13
|
-
def format(warning)
|
14
|
-
"#{super} [#{warning.explanatory_link}]"
|
15
|
-
end
|
16
|
-
|
17
|
-
def format_hash(warning)
|
18
|
-
super.merge('wiki_link' => warning.explanatory_link)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'base_detector'
|
4
|
-
|
5
|
-
module Reek
|
6
|
-
module SmellDetectors
|
7
|
-
# Check syntax errors.
|
8
|
-
# Note: this detector is called by examiner directly unlike other detectors.
|
9
|
-
class Syntax < BaseDetector
|
10
|
-
# Context duck type for this atypical smell detector
|
11
|
-
DummyContext = Struct.new(:exp, :full_name)
|
12
|
-
# Exp duck type for this atypical smell detector
|
13
|
-
DummyExp = Struct.new(:source)
|
14
|
-
|
15
|
-
def self.contexts
|
16
|
-
[]
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.smells_from_source(source)
|
20
|
-
new.smells_from_source(source)
|
21
|
-
end
|
22
|
-
|
23
|
-
# :reek:FeatureEnvy
|
24
|
-
def smells_from_source(source)
|
25
|
-
context = DummyContext.new(
|
26
|
-
DummyExp.new(source.origin),
|
27
|
-
'This file')
|
28
|
-
source.diagnostics.map do |diagnostic|
|
29
|
-
smell_warning(
|
30
|
-
context: context,
|
31
|
-
lines: [diagnostic.location.line],
|
32
|
-
message: "has #{diagnostic.message}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# Smelly class for testing purposes
|
2
|
-
#
|
3
|
-
# Not necessary for the feature per se but for
|
4
|
-
# removing distracting output. :reek:UnusedPrivateMethod
|
5
|
-
#
|
6
|
-
class Klass
|
7
|
-
def public_method(arg) arg.to_s; end
|
8
|
-
protected
|
9
|
-
def protected_method(arg) arg.to_s; end
|
10
|
-
private
|
11
|
-
def private_method(arg) arg.to_s; end
|
12
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/smell_detectors/syntax'
|
3
|
-
|
4
|
-
RSpec.describe Reek::SmellDetectors::Syntax do
|
5
|
-
it 'reports the right values' do
|
6
|
-
src = <<-EOS
|
7
|
-
class Alfa
|
8
|
-
edn
|
9
|
-
EOS
|
10
|
-
|
11
|
-
expect(src).to reek_of(:Syntax,
|
12
|
-
lines: [3],
|
13
|
-
context: 'This file',
|
14
|
-
message: 'has unexpected token $end',
|
15
|
-
source: 'string')
|
16
|
-
end
|
17
|
-
end
|