reek 2.0.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +13 -0
- data/.rubocop.yml +47 -0
- data/.travis.yml +31 -0
- data/.yardopts +3 -6
- data/CHANGELOG +24 -0
- data/CONTRIBUTING.md +111 -0
- data/Gemfile +16 -0
- data/README.md +112 -59
- data/bin/reek +2 -2
- data/config/cucumber.yml +3 -0
- data/config/defaults.reek +0 -1
- data/docs/API.md +79 -0
- data/docs/Attribute.md +43 -0
- data/docs/Basic-Smell-Options.md +44 -0
- data/docs/Boolean-Parameter.md +52 -0
- data/docs/Class-Variable.md +40 -0
- data/docs/Code-Smells.md +34 -0
- data/docs/Command-Line-Options.md +84 -0
- data/docs/Configuration-Files.md +49 -0
- data/docs/Control-Couple.md +22 -0
- data/docs/Control-Parameter.md +29 -0
- data/docs/Data-Clump.md +44 -0
- data/docs/Duplicate-Method-Call.md +49 -0
- data/docs/Feature-Envy.md +49 -0
- data/docs/How-reek-works-internally.md +114 -0
- data/docs/Irresponsible-Module.md +39 -0
- data/docs/Large-Class.md +20 -0
- data/docs/Long-Parameter-List.md +38 -0
- data/docs/Long-Yield-List.md +36 -0
- data/docs/Module-Initialize.md +62 -0
- data/docs/Nested-Iterators.md +38 -0
- data/docs/Nil-Check.md +39 -0
- data/docs/Prima-Donna-Method.md +53 -0
- data/docs/RSpec-matchers.md +137 -0
- data/docs/Rake-Task.md +58 -0
- data/docs/Reek-Driven-Development.md +37 -0
- data/docs/Repeated-Conditional.md +44 -0
- data/docs/Simulated-Polymorphism.md +16 -0
- data/docs/Smell-Suppression.md +32 -0
- data/docs/Too-Many-Instance-Variables.md +43 -0
- data/docs/Too-Many-Methods.md +55 -0
- data/docs/Too-Many-Statements.md +50 -0
- data/docs/Uncommunicative-Method-Name.md +24 -0
- data/docs/Uncommunicative-Module-Name.md +23 -0
- data/docs/Uncommunicative-Name.md +16 -0
- data/docs/Uncommunicative-Parameter-Name.md +24 -0
- data/docs/Uncommunicative-Variable-Name.md +24 -0
- data/docs/Unused-Parameters.md +27 -0
- data/docs/Utility-Function.md +44 -0
- data/docs/Versioning-Policy.md +7 -0
- data/docs/YAML-Reports.md +111 -0
- data/docs/yard_plugin.rb +14 -0
- data/features/{ruby_api/api.feature → command_line_interface/basic_usage.feature} +6 -5
- data/features/command_line_interface/options.feature +1 -0
- data/features/command_line_interface/smell_selection.feature +4 -8
- data/features/command_line_interface/smells_count.feature +25 -32
- data/features/command_line_interface/stdin.feature +2 -2
- data/features/configuration_files/masking_smells.feature +30 -41
- data/features/configuration_files/overrides_defaults.feature +5 -3
- data/features/configuration_loading.feature +26 -23
- data/features/programmatic_access.feature +43 -0
- data/features/rake_task/rake_task.feature +25 -22
- data/features/reports/json.feature +24 -26
- data/features/reports/reports.feature +77 -103
- data/features/reports/yaml.feature +26 -20
- data/features/samples.feature +26 -31
- data/features/step_definitions/.rubocop.yml +5 -0
- data/features/step_definitions/reek_steps.rb +16 -28
- data/features/step_definitions/sample_file_steps.rb +158 -0
- data/features/support/env.rb +16 -27
- data/lib/reek/{source → ast}/ast_node_class_map.rb +11 -12
- data/lib/reek/ast/node.rb +132 -0
- data/lib/reek/{core → ast}/object_refs.rb +2 -1
- data/lib/reek/ast/reference_collector.rb +32 -0
- data/lib/reek/{source → ast}/sexp_extensions.rb +43 -7
- data/lib/reek/ast/sexp_formatter.rb +31 -0
- data/lib/reek/cli/application.rb +5 -4
- data/lib/reek/cli/command.rb +2 -1
- data/lib/reek/cli/input.rb +6 -5
- data/lib/reek/cli/option_interpreter.rb +13 -9
- data/lib/reek/cli/options.rb +16 -8
- data/lib/reek/cli/reek_command.rb +4 -3
- data/lib/reek/cli/silencer.rb +14 -0
- data/lib/reek/{core → cli}/warning_collector.rb +2 -1
- data/lib/reek/code_comment.rb +36 -0
- data/lib/reek/configuration/app_configuration.rb +18 -3
- data/lib/reek/configuration/configuration_file_finder.rb +18 -32
- data/lib/reek/{core → context}/code_context.rb +8 -6
- data/lib/reek/{core → context}/method_context.rb +11 -5
- data/lib/reek/{core → context}/module_context.rb +9 -4
- data/lib/reek/{core/stop_context.rb → context/root_context.rb} +4 -2
- data/lib/reek/{core → context}/singleton_method_context.rb +3 -6
- data/lib/reek/examiner.rb +32 -29
- data/lib/reek/report/formatter.rb +70 -0
- data/lib/reek/report/heading_formatter.rb +45 -0
- data/lib/reek/report/location_formatter.rb +35 -0
- data/lib/reek/report/report.rb +198 -0
- data/lib/reek/smells/attribute.rb +41 -11
- data/lib/reek/smells/boolean_parameter.rb +4 -2
- data/lib/reek/smells/class_variable.rb +4 -2
- data/lib/reek/smells/control_parameter.rb +4 -2
- data/lib/reek/smells/data_clump.rb +4 -3
- data/lib/reek/smells/duplicate_method_call.rb +15 -5
- data/lib/reek/smells/feature_envy.rb +8 -2
- data/lib/reek/smells/irresponsible_module.rb +13 -8
- data/lib/reek/smells/long_parameter_list.rb +6 -4
- data/lib/reek/smells/long_yield_list.rb +4 -2
- data/lib/reek/smells/module_initialize.rb +4 -2
- data/lib/reek/smells/nested_iterators.rb +4 -2
- data/lib/reek/smells/nil_check.rb +6 -3
- data/lib/reek/smells/prima_donna_method.rb +21 -12
- data/lib/reek/smells/repeated_conditional.rb +7 -4
- data/lib/reek/{core → smells}/smell_configuration.rb +3 -1
- data/lib/reek/smells/smell_detector.rb +11 -5
- data/lib/reek/{core → smells}/smell_repository.rb +9 -5
- data/lib/reek/smells/smell_warning.rb +101 -0
- data/lib/reek/smells/too_many_instance_variables.rb +4 -2
- data/lib/reek/smells/too_many_methods.rb +4 -2
- data/lib/reek/smells/too_many_statements.rb +4 -2
- data/lib/reek/smells/uncommunicative_method_name.rb +4 -2
- data/lib/reek/smells/uncommunicative_module_name.rb +4 -2
- data/lib/reek/smells/uncommunicative_parameter_name.rb +4 -2
- data/lib/reek/smells/uncommunicative_variable_name.rb +4 -2
- data/lib/reek/smells/unused_parameters.rb +4 -2
- data/lib/reek/smells/utility_function.rb +11 -22
- data/lib/reek/smells.rb +24 -11
- data/lib/reek/source/source_code.rb +69 -12
- data/lib/reek/source/source_locator.rb +34 -19
- data/lib/reek/spec/should_reek.rb +4 -3
- data/lib/reek/spec/should_reek_of.rb +2 -1
- data/lib/reek/spec/should_reek_only_of.rb +4 -3
- data/lib/reek/spec.rb +3 -3
- data/lib/reek/tree_dresser.rb +32 -0
- data/lib/reek/tree_walker.rb +182 -0
- data/lib/reek/version.rb +1 -1
- data/lib/reek.rb +3 -3
- data/reek.gemspec +18 -25
- data/spec/factories/factories.rb +4 -2
- data/spec/gem/updates_spec.rb +1 -1
- data/spec/gem/yard_spec.rb +2 -2
- data/spec/quality/reek_source_spec.rb +3 -3
- data/spec/reek/{source/sexp_node_spec.rb → ast/node_spec.rb} +4 -6
- data/spec/reek/{core → ast}/object_refs_spec.rb +4 -6
- data/spec/reek/{source → ast}/reference_collector_spec.rb +27 -19
- data/spec/reek/{source → ast}/sexp_extensions_spec.rb +7 -19
- data/spec/reek/{source → ast}/sexp_formatter_spec.rb +13 -8
- data/spec/reek/cli/option_interpreter_spec.rb +15 -0
- data/spec/reek/cli/options_spec.rb +19 -0
- data/spec/reek/cli/warning_collector_spec.rb +28 -0
- data/spec/reek/{source/code_comment_spec.rb → code_comment_spec.rb} +19 -17
- data/spec/reek/configuration/app_configuration_spec.rb +37 -26
- data/spec/reek/configuration/configuration_file_finder_spec.rb +67 -21
- data/spec/reek/{core → context}/code_context_spec.rb +18 -21
- data/spec/reek/{core → context}/method_context_spec.rb +33 -27
- data/spec/reek/{core → context}/module_context_spec.rb +5 -7
- data/spec/reek/context/root_context_spec.rb +14 -0
- data/spec/reek/context/singleton_method_context_spec.rb +17 -0
- data/spec/reek/examiner_spec.rb +9 -50
- data/spec/reek/{cli → report}/html_report_spec.rb +6 -9
- data/spec/reek/report/json_report_spec.rb +20 -0
- data/spec/reek/{cli → report}/text_report_spec.rb +16 -19
- data/spec/reek/report/xml_report_spec.rb +34 -0
- data/spec/reek/report/yaml_report_spec.rb +20 -0
- data/spec/reek/smells/attribute_spec.rb +93 -88
- data/spec/reek/smells/behaves_like_variable_detector.rb +1 -1
- data/spec/reek/smells/boolean_parameter_spec.rb +31 -5
- data/spec/reek/smells/class_variable_spec.rb +10 -10
- data/spec/reek/smells/control_parameter_spec.rb +5 -5
- data/spec/reek/smells/data_clump_spec.rb +6 -6
- data/spec/reek/smells/duplicate_method_call_spec.rb +7 -7
- data/spec/reek/smells/feature_envy_spec.rb +12 -13
- data/spec/reek/smells/irresponsible_module_spec.rb +28 -32
- data/spec/reek/smells/long_parameter_list_spec.rb +7 -7
- data/spec/reek/smells/long_yield_list_spec.rb +6 -6
- data/spec/reek/smells/module_initialize_spec.rb +4 -4
- data/spec/reek/smells/nested_iterators_spec.rb +6 -6
- data/spec/reek/smells/nil_check_spec.rb +6 -6
- data/spec/reek/smells/prima_donna_method_spec.rb +8 -5
- data/spec/reek/smells/repeated_conditional_spec.rb +18 -17
- data/spec/reek/{core → smells}/smell_configuration_spec.rb +5 -7
- data/spec/reek/smells/smell_detector_shared.rb +6 -7
- data/spec/reek/smells/smell_repository_spec.rb +29 -0
- data/spec/reek/{smell_warning_spec.rb → smells/smell_warning_spec.rb} +7 -9
- data/spec/reek/smells/too_many_instance_variables_spec.rb +5 -5
- data/spec/reek/smells/too_many_methods_spec.rb +12 -8
- data/spec/reek/smells/too_many_statements_spec.rb +10 -9
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +5 -5
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +8 -8
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +18 -6
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +10 -7
- data/spec/reek/smells/unused_parameters_spec.rb +4 -4
- data/spec/reek/smells/utility_function_spec.rb +65 -39
- data/spec/reek/source/source_code_spec.rb +10 -10
- data/spec/reek/source/source_locator_spec.rb +30 -0
- data/spec/reek/spec/should_reek_of_spec.rb +9 -25
- data/spec/reek/spec/should_reek_only_of_spec.rb +4 -7
- data/spec/reek/spec/should_reek_spec.rb +4 -32
- data/spec/reek/tree_dresser_spec.rb +16 -0
- data/spec/reek/{core/tree_walker_spec.rb → tree_walker_spec.rb} +5 -7
- data/spec/samples/checkstyle.xml +2 -0
- data/spec/samples/configuration/with_excluded_paths.reek +4 -0
- data/spec/samples/{overrides/masked/lower.reek → masked_by_dotfile/.reek} +3 -1
- data/spec/samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +5 -0
- data/spec/samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +2 -0
- data/spec/samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +6 -0
- data/spec/samples/{ruby20_syntax.rb → unusual_syntax.rb} +8 -0
- data/spec/spec_helper.rb +21 -10
- data/tasks/develop.rake +2 -2
- data/tasks/reek.rake +1 -1
- metadata +158 -141
- data/features/support/hooks.rb +0 -15
- data/lib/reek/cli/report/formatter.rb +0 -69
- data/lib/reek/cli/report/heading_formatter.rb +0 -45
- data/lib/reek/cli/report/location_formatter.rb +0 -34
- data/lib/reek/cli/report/report.rb +0 -131
- data/lib/reek/core/tree_walker.rb +0 -180
- data/lib/reek/smell_warning.rb +0 -87
- data/lib/reek/source/ast_node.rb +0 -38
- data/lib/reek/source/code_comment.rb +0 -37
- data/lib/reek/source/core_extras.rb +0 -46
- data/lib/reek/source/reference_collector.rb +0 -27
- data/lib/reek/source/sexp_formatter.rb +0 -22
- data/lib/reek/source/sexp_node.rb +0 -79
- data/lib/reek/source/source_file.rb +0 -16
- data/lib/reek/source/source_repository.rb +0 -45
- data/lib/reek/source/tree_dresser.rb +0 -24
- data/lib/reek/source.rb +0 -16
- data/spec/reek/cli/json_report_spec.rb +0 -20
- data/spec/reek/cli/option_interperter_spec.rb +0 -14
- data/spec/reek/cli/yaml_report_spec.rb +0 -23
- data/spec/reek/core/singleton_method_context_spec.rb +0 -9
- data/spec/reek/core/smell_repository_spec.rb +0 -17
- data/spec/reek/core/stop_context_spec.rb +0 -17
- data/spec/reek/core/warning_collector_spec.rb +0 -30
- data/spec/reek/source/object_source_spec.rb +0 -20
- data/spec/reek/source/tree_dresser_spec.rb +0 -18
- data/spec/samples/config/allow_duplication.reek +0 -3
- data/spec/samples/config/deeper_nested_iterators.reek +0 -3
- data/spec/samples/configuration_loading/minimal_dirty.rb +0 -4
- data/spec/samples/configuration_loading/reek-test-run-disable_smells.reek +0 -7
- data/spec/samples/configuration_loading/reek-test-run-enable_smells.reek +0 -7
- data/spec/samples/corrupt_config_file/corrupt.reek +0 -1
- data/spec/samples/corrupt_config_file/dirty.rb +0 -8
- data/spec/samples/demo/demo.rb +0 -8
- data/spec/samples/empty_config_file/dirty.rb +0 -8
- data/spec/samples/empty_config_file/empty.reek +0 -0
- data/spec/samples/inline_config/dirty.rb +0 -16
- data/spec/samples/inline_config/masked.reek +0 -7
- data/spec/samples/mask_some/dirty.rb +0 -8
- data/spec/samples/mask_some/some.reek +0 -8
- data/spec/samples/masked/dirty.rb +0 -8
- data/spec/samples/masked/masked.reek +0 -5
- data/spec/samples/minimal_smelly_and_masked/config.reek +0 -7
- data/spec/samples/minimal_smelly_and_masked/minimal_dirty.rb +0 -4
- data/spec/samples/mixed_results/clean_one.rb +0 -7
- data/spec/samples/mixed_results/clean_three.rb +0 -7
- data/spec/samples/mixed_results/clean_two.rb +0 -7
- data/spec/samples/mixed_results/dirty_one.rb +0 -8
- data/spec/samples/mixed_results/dirty_two.rb +0 -8
- data/spec/samples/not_quite_masked/dirty.rb +0 -8
- data/spec/samples/not_quite_masked/masked.reek +0 -5
- data/spec/samples/not_quite_masked/smelly.rb +0 -3
- data/spec/samples/one_smelly_file/dirty.rb +0 -3
- data/spec/samples/overrides/masked/dirty.rb +0 -8
- data/spec/samples/overrides/upper.reek +0 -5
- data/spec/samples/overrides_defaults/camel_case.rb +0 -14
- data/spec/samples/overrides_defaults/config.reek +0 -6
- data/spec/samples/ruby21_syntax.rb +0 -5
- data/spec/samples/standard_smelly/dirty.rb +0 -8
- data/spec/samples/standard_smelly/minimal_dirty.rb +0 -4
- data/spec/samples/three_smelly_files/dirty_one.rb +0 -3
- data/spec/samples/three_smelly_files/dirty_three.rb +0 -5
- data/spec/samples/three_smelly_files/dirty_two.rb +0 -4
- /data/spec/samples/{simple_configuration.reek → configuration/simple_configuration.reek} +0 -0
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
old_verbose, $VERBOSE = $VERBOSE, nil
|
|
2
|
-
require 'unparser'
|
|
3
|
-
$VERBOSE = old_verbose
|
|
4
|
-
|
|
5
|
-
module Reek
|
|
6
|
-
module Source
|
|
7
|
-
#
|
|
8
|
-
# Formats snippets of syntax tree back into Ruby source code.
|
|
9
|
-
#
|
|
10
|
-
class SexpFormatter
|
|
11
|
-
def self.format(sexp)
|
|
12
|
-
return sexp.to_s unless sexp.is_a? AST::Node
|
|
13
|
-
lines = Unparser.unparse(sexp).split "\n"
|
|
14
|
-
if lines.length > 1
|
|
15
|
-
"#{lines.first} ... #{lines.last}"
|
|
16
|
-
else
|
|
17
|
-
lines.first
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
module Reek
|
|
2
|
-
module Source
|
|
3
|
-
#
|
|
4
|
-
# Extensions to +Sexp+ to allow +TreeWalker+ to navigate the abstract
|
|
5
|
-
# syntax tree more easily.
|
|
6
|
-
#
|
|
7
|
-
module SexpNode
|
|
8
|
-
def self.format(expr)
|
|
9
|
-
case expr
|
|
10
|
-
when AST::Node then expr.format_ruby
|
|
11
|
-
else expr.to_s
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def hash
|
|
16
|
-
inspect.hash
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def each_node(type, ignoring = [], &blk)
|
|
20
|
-
if block_given?
|
|
21
|
-
look_for(type, ignoring, &blk)
|
|
22
|
-
else
|
|
23
|
-
result = []
|
|
24
|
-
look_for(type, ignoring) { |exp| result << exp }
|
|
25
|
-
result
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def find_nodes(types, ignoring = [])
|
|
30
|
-
result = []
|
|
31
|
-
look_for_alt(types, ignoring) { |exp| result << exp }
|
|
32
|
-
result
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def each_sexp
|
|
36
|
-
children.each { |elem| yield elem if elem.is_a? AST::Node }
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
#
|
|
40
|
-
# Carries out a depth-first traversal of this syntax tree, yielding
|
|
41
|
-
# every Sexp of type +target_type+. The traversal ignores any node
|
|
42
|
-
# whose type is listed in the Array +ignoring+.
|
|
43
|
-
#
|
|
44
|
-
def look_for(target_type, ignoring = [], &blk)
|
|
45
|
-
each_sexp do |elem|
|
|
46
|
-
elem.look_for(target_type, ignoring, &blk) unless ignoring.include?(elem.type)
|
|
47
|
-
end
|
|
48
|
-
blk.call(self) if type == target_type
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
#
|
|
52
|
-
# Carries out a depth-first traversal of this syntax tree, yielding
|
|
53
|
-
# every Sexp of type +target_type+. The traversal ignores any node
|
|
54
|
-
# whose type is listed in the Array +ignoring+, includeing the top node.
|
|
55
|
-
#
|
|
56
|
-
# Also, doesn't nest
|
|
57
|
-
#
|
|
58
|
-
def look_for_alt(target_types, ignoring = [], &blk)
|
|
59
|
-
return if ignoring.include?(type)
|
|
60
|
-
if target_types.include? type
|
|
61
|
-
blk.call(self)
|
|
62
|
-
else
|
|
63
|
-
each_sexp do |elem|
|
|
64
|
-
elem.look_for_alt(target_types, ignoring, &blk)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def contains_nested_node?(target_type)
|
|
70
|
-
look_for(target_type) { |_elem| return true }
|
|
71
|
-
false
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def format_ruby
|
|
75
|
-
SexpFormatter.format(self)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
require 'reek/source/source_code'
|
|
2
|
-
|
|
3
|
-
module Reek
|
|
4
|
-
module Source
|
|
5
|
-
#
|
|
6
|
-
# Represents a file of Ruby source, whose contents will be examined
|
|
7
|
-
# for code smells.
|
|
8
|
-
#
|
|
9
|
-
class SourceFile < SourceCode
|
|
10
|
-
def initialize(path)
|
|
11
|
-
@path = path
|
|
12
|
-
super(IO.readlines(@path).join, @path)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require 'reek/source/core_extras'
|
|
2
|
-
require 'reek/source/source_code'
|
|
3
|
-
require 'reek/source/source_locator'
|
|
4
|
-
|
|
5
|
-
module Reek
|
|
6
|
-
module Source
|
|
7
|
-
#
|
|
8
|
-
# A collection of source code. If the collection is initialized with an array
|
|
9
|
-
# it is assumed to be a list of file paths. Otherwise it is assumed to be a
|
|
10
|
-
# single unit of Ruby source code.
|
|
11
|
-
#
|
|
12
|
-
class SourceRepository
|
|
13
|
-
# TODO: This method is a least partially broken.
|
|
14
|
-
# Regardless of how you call reek, be it:
|
|
15
|
-
# reek lib/
|
|
16
|
-
# reek lib/file_one.rb lib/file_two.rb
|
|
17
|
-
# echo "def m; end" | reek
|
|
18
|
-
# we *always* end up in the "when Source::SourceCode" branch.
|
|
19
|
-
# So it seems like 80% of this method is never used.
|
|
20
|
-
def self.parse(source)
|
|
21
|
-
case source
|
|
22
|
-
when Array
|
|
23
|
-
new 'dir', Source::SourceLocator.new(source).all_sources
|
|
24
|
-
when Source::SourceCode
|
|
25
|
-
new source.desc, [source]
|
|
26
|
-
else
|
|
27
|
-
src = source.to_reek_source
|
|
28
|
-
new src.desc, [src]
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
include Enumerable
|
|
33
|
-
attr_reader :description
|
|
34
|
-
|
|
35
|
-
def initialize(description, sources)
|
|
36
|
-
@description = description
|
|
37
|
-
@sources = sources
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def each(&block)
|
|
41
|
-
@sources.each(&block)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require 'reek/source/ast_node_class_map'
|
|
2
|
-
|
|
3
|
-
module Reek
|
|
4
|
-
module Source
|
|
5
|
-
#
|
|
6
|
-
# Adorns an abstract syntax tree with mix-in modules to make accessing
|
|
7
|
-
# the tree more understandable and less implementation-dependent.
|
|
8
|
-
#
|
|
9
|
-
class TreeDresser
|
|
10
|
-
def initialize(klass_map = AstNodeClassMap.new)
|
|
11
|
-
@klass_map = klass_map
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def dress(sexp, comment_map)
|
|
15
|
-
return sexp unless sexp.is_a? AST::Node
|
|
16
|
-
type = sexp.type
|
|
17
|
-
children = sexp.children.map { |child| dress(child, comment_map) }
|
|
18
|
-
comments = comment_map[sexp]
|
|
19
|
-
@klass_map.klass_for(type).new(type, children,
|
|
20
|
-
location: sexp.loc, comments: comments)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
data/lib/reek/source.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
require 'reek/source/code_comment'
|
|
2
|
-
require 'reek/source/core_extras'
|
|
3
|
-
require 'reek/source/sexp_formatter'
|
|
4
|
-
require 'reek/source/source_code'
|
|
5
|
-
require 'reek/source/source_file'
|
|
6
|
-
require 'reek/source/source_locator'
|
|
7
|
-
require 'reek/source/tree_dresser'
|
|
8
|
-
|
|
9
|
-
module Reek
|
|
10
|
-
#
|
|
11
|
-
# This module contains a set of classes for interacting with Ruby
|
|
12
|
-
# source code and abstract syntax trees.
|
|
13
|
-
#
|
|
14
|
-
module Source # :nodoc: all
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'reek/examiner'
|
|
3
|
-
require 'reek/cli/report/report'
|
|
4
|
-
require 'reek/cli/report/formatter'
|
|
5
|
-
|
|
6
|
-
describe Reek::Cli::Report::JsonReport do
|
|
7
|
-
let(:instance) { Reek::Cli::Report::JsonReport.new }
|
|
8
|
-
|
|
9
|
-
context 'empty source' do
|
|
10
|
-
let(:examiner) { Reek::Examiner.new('') }
|
|
11
|
-
|
|
12
|
-
before do
|
|
13
|
-
instance.add_examiner examiner
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'prints empty json' do
|
|
17
|
-
expect { instance.show }.to output(/^\[\]$/).to_stdout
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
require 'reek/cli/options'
|
|
4
|
-
|
|
5
|
-
describe Reek::Cli::OptionInterpreter do
|
|
6
|
-
let(:options) { OpenStruct.new }
|
|
7
|
-
let(:instance) { Reek::Cli::OptionInterpreter.new(options) }
|
|
8
|
-
|
|
9
|
-
describe '#reporter' do
|
|
10
|
-
it 'returns a Report::TextReport instance by default' do
|
|
11
|
-
expect(instance.reporter).to be_instance_of Reek::Cli::Report::TextReport
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'reek/examiner'
|
|
3
|
-
require 'reek/cli/report/report'
|
|
4
|
-
require 'reek/cli/report/formatter'
|
|
5
|
-
|
|
6
|
-
include Reek
|
|
7
|
-
include Reek::Cli
|
|
8
|
-
|
|
9
|
-
describe Report::YamlReport do
|
|
10
|
-
let(:instance) { Report::YamlReport.new }
|
|
11
|
-
|
|
12
|
-
context 'empty source' do
|
|
13
|
-
let(:examiner) { Examiner.new('') }
|
|
14
|
-
|
|
15
|
-
before do
|
|
16
|
-
instance.add_examiner examiner
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'prints empty yaml' do
|
|
20
|
-
expect { instance.show }.to output(/^--- \[\]\n.*$/).to_stdout
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'reek/core/smell_repository'
|
|
3
|
-
|
|
4
|
-
include Reek::Core
|
|
5
|
-
|
|
6
|
-
describe SmellRepository do
|
|
7
|
-
describe '.smell_types' do
|
|
8
|
-
it 'should include existing smell_types' do
|
|
9
|
-
expect(SmellRepository.smell_types).to include(Reek::Smells::IrresponsibleModule)
|
|
10
|
-
expect(SmellRepository.smell_types).to include(Reek::Smells::TooManyStatements)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'should exclude certain smell_types' do
|
|
14
|
-
expect(SmellRepository.smell_types).to_not include(Reek::Smells::SmellDetector)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'reek/core/stop_context'
|
|
3
|
-
|
|
4
|
-
include Reek
|
|
5
|
-
include Reek::Core
|
|
6
|
-
|
|
7
|
-
describe StopContext do
|
|
8
|
-
before :each do
|
|
9
|
-
@stop = StopContext.new
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context 'full_name' do
|
|
13
|
-
it 'reports full context' do
|
|
14
|
-
expect(@stop.full_name).to eq('')
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'reek/core/warning_collector'
|
|
3
|
-
require 'reek/smell_warning'
|
|
4
|
-
|
|
5
|
-
include Reek::Core
|
|
6
|
-
|
|
7
|
-
describe WarningCollector do
|
|
8
|
-
before(:each) do
|
|
9
|
-
@collector = WarningCollector.new
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context 'when empty' do
|
|
13
|
-
it 'reports no warnings' do
|
|
14
|
-
expect(@collector.warnings).to eq([])
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context 'with one warning' do
|
|
19
|
-
before :each do
|
|
20
|
-
@warning = Reek::SmellWarning.new(Reek::Smells::FeatureEnvy.new(''),
|
|
21
|
-
context: 'fred',
|
|
22
|
-
lines: [1, 2, 3],
|
|
23
|
-
message: 'hello')
|
|
24
|
-
@collector.found_smell(@warning)
|
|
25
|
-
end
|
|
26
|
-
it 'reports that warning' do
|
|
27
|
-
expect(@collector.warnings).to eq([@warning])
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
include Reek
|
|
4
|
-
|
|
5
|
-
describe Dir do
|
|
6
|
-
it 'reports correct smells via the Dir matcher' do
|
|
7
|
-
files = Dir['spec/samples/two_smelly_files/*.rb']
|
|
8
|
-
expect(files).to reek
|
|
9
|
-
expect(files).to reek_of(:UncommunicativeVariableName)
|
|
10
|
-
expect(files).not_to reek_of(:LargeClass)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'copes with daft file specs' do
|
|
14
|
-
expect(Dir['spec/samples/two_smelly_files/*/.rb']).not_to reek
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'copes with empty array' do
|
|
18
|
-
expect([]).not_to reek
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'reek/source/tree_dresser'
|
|
3
|
-
|
|
4
|
-
include Reek::Source
|
|
5
|
-
|
|
6
|
-
describe TreeDresser do
|
|
7
|
-
let(:ifnode) { Parser::AST::Node.new(:if) }
|
|
8
|
-
let(:sendnode) { Parser::AST::Node.new(:send) }
|
|
9
|
-
let(:dresser) { TreeDresser.new }
|
|
10
|
-
|
|
11
|
-
it 'dresses :if sexp with IfNode' do
|
|
12
|
-
expect(dresser.dress(ifnode, {})).to be_a Reek::Source::SexpExtensions::IfNode
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'dresses :send sexp with SendNode' do
|
|
16
|
-
expect(dresser.dress(sendnode, {})).to be_a Reek::Source::SexpExtensions::SendNode
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This is not a config file
|
data/spec/samples/demo/demo.rb
DELETED
|
File without changes
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# :reek:DuplicateMethodCall: { allow_calls: [ puts ] }
|
|
2
|
-
# smells of :reek:NestedIterators but ignores them
|
|
3
|
-
class Dirty
|
|
4
|
-
def a
|
|
5
|
-
puts @s.title
|
|
6
|
-
@s = fred.map {|x| x.each {|key| key += 3}}
|
|
7
|
-
puts @s.title
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
# :reek:DuplicateMethodCall: { max_calls: 2 }
|
|
11
|
-
def b
|
|
12
|
-
puts @s.title
|
|
13
|
-
@s = fred.map {|x| x.each {|key| key += 3}}
|
|
14
|
-
puts @s.title
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Class containing camelCase variable which would normally smell
|
|
2
|
-
class CamelCase
|
|
3
|
-
def initialize
|
|
4
|
-
# These next two would normally smell if it weren't for overridden config values
|
|
5
|
-
camelCaseVariable = []
|
|
6
|
-
anotherOne = 1
|
|
7
|
-
|
|
8
|
-
# this next one should still smell
|
|
9
|
-
x1 = 0
|
|
10
|
-
|
|
11
|
-
# this next one should not smell
|
|
12
|
-
should_not_smell = true
|
|
13
|
-
end
|
|
14
|
-
end
|