reek 2.1.0 → 2.2.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/.rubocop.yml +2 -21
- data/.travis.yml +1 -0
- data/.yardopts +3 -6
- data/CHANGELOG +6 -0
- data/CONTRIBUTING.md +8 -3
- data/README.md +94 -42
- data/config/defaults.reek +0 -1
- data/docs/API.md +50 -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 +38 -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 +29 -0
- data/docs/How-reek-works-internally.md +44 -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 +133 -0
- data/docs/Rake-Task.md +58 -0
- data/docs/Reek-Driven-Development.md +45 -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 +46 -0
- data/docs/Versioning-Policy.md +7 -0
- data/docs/YAML-Reports.md +111 -0
- data/docs/yard_plugin.rb +14 -0
- data/features/command_line_interface/options.feature +1 -0
- data/features/programmatic_access.feature +1 -1
- data/features/samples.feature +3 -3
- data/lib/reek.rb +2 -2
- data/lib/reek/cli/input.rb +2 -2
- data/lib/reek/cli/option_interpreter.rb +2 -0
- data/lib/reek/cli/options.rb +10 -4
- data/lib/reek/cli/reek_command.rb +2 -2
- data/lib/reek/cli/report/report.rb +60 -0
- data/lib/reek/cli/silencer.rb +13 -0
- data/lib/reek/{source → core}/ast_node.rb +1 -1
- data/lib/reek/{source → core}/ast_node_class_map.rb +10 -11
- data/lib/reek/{source → core}/code_comment.rb +1 -1
- data/lib/reek/core/code_context.rb +1 -1
- data/lib/reek/core/examiner.rb +85 -0
- data/lib/reek/core/method_context.rb +1 -1
- data/lib/reek/core/module_context.rb +2 -2
- data/lib/reek/core/reference_collector.rb +31 -0
- data/lib/reek/core/singleton_method_context.rb +0 -4
- data/lib/reek/core/smell_repository.rb +4 -2
- data/lib/reek/{source → core}/tree_dresser.rb +1 -1
- data/lib/reek/{source → sexp}/sexp_extensions.rb +5 -5
- data/lib/reek/sexp/sexp_formatter.rb +29 -0
- data/lib/reek/sexp/sexp_node.rb +91 -0
- data/lib/reek/smells.rb +4 -2
- data/lib/reek/smells/attribute.rb +35 -7
- data/lib/reek/smells/boolean_parameter.rb +1 -1
- data/lib/reek/smells/class_variable.rb +1 -1
- data/lib/reek/smells/control_parameter.rb +1 -1
- data/lib/reek/smells/data_clump.rb +1 -1
- data/lib/reek/smells/duplicate_method_call.rb +12 -4
- data/lib/reek/smells/feature_envy.rb +1 -1
- data/lib/reek/smells/irresponsible_module.rb +3 -3
- data/lib/reek/smells/long_parameter_list.rb +1 -1
- data/lib/reek/smells/long_yield_list.rb +1 -1
- data/lib/reek/smells/module_initialize.rb +1 -1
- data/lib/reek/smells/nested_iterators.rb +1 -1
- data/lib/reek/smells/nil_check.rb +3 -2
- data/lib/reek/smells/prima_donna_method.rb +18 -11
- data/lib/reek/smells/repeated_conditional.rb +3 -3
- data/lib/reek/smells/smell_detector.rb +5 -1
- data/lib/reek/smells/smell_warning.rb +99 -0
- data/lib/reek/smells/too_many_instance_variables.rb +1 -1
- data/lib/reek/smells/too_many_methods.rb +1 -1
- data/lib/reek/smells/too_many_statements.rb +1 -1
- data/lib/reek/smells/uncommunicative_method_name.rb +1 -1
- data/lib/reek/smells/uncommunicative_module_name.rb +1 -1
- data/lib/reek/smells/uncommunicative_parameter_name.rb +1 -1
- data/lib/reek/smells/uncommunicative_variable_name.rb +1 -1
- data/lib/reek/smells/unused_parameters.rb +1 -1
- data/lib/reek/smells/utility_function.rb +3 -16
- data/lib/reek/source/source_code.rb +31 -13
- data/lib/reek/source/source_locator.rb +16 -17
- data/lib/reek/source/source_repository.rb +10 -11
- data/lib/reek/spec/should_reek.rb +2 -2
- data/lib/reek/spec/should_reek_of.rb +2 -2
- data/lib/reek/spec/should_reek_only_of.rb +2 -2
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +3 -4
- data/spec/factories/factories.rb +1 -1
- data/spec/gem/yard_spec.rb +1 -1
- data/spec/quality/reek_source_spec.rb +2 -2
- data/spec/reek/cli/html_report_spec.rb +3 -3
- data/spec/reek/cli/json_report_spec.rb +3 -3
- data/spec/reek/cli/{option_interperter_spec.rb → option_interpreter_spec.rb} +1 -1
- data/spec/reek/cli/options_spec.rb +19 -0
- data/spec/reek/cli/text_report_spec.rb +7 -7
- data/spec/reek/cli/xml_report_spec.rb +34 -0
- data/spec/reek/cli/yaml_report_spec.rb +3 -3
- data/spec/reek/configuration/app_configuration_spec.rb +1 -1
- data/spec/reek/configuration/configuration_file_finder_spec.rb +22 -1
- data/spec/reek/{source → core}/code_comment_spec.rb +14 -14
- data/spec/reek/core/code_context_spec.rb +1 -1
- data/spec/reek/{examiner_spec.rb → core/examiner_spec.rb} +12 -12
- data/spec/reek/core/method_context_spec.rb +27 -22
- data/spec/reek/core/module_context_spec.rb +2 -2
- data/spec/reek/core/object_refs_spec.rb +1 -1
- data/spec/reek/{source → core}/object_source_spec.rb +1 -1
- data/spec/reek/{source → core}/reference_collector_spec.rb +25 -16
- data/spec/reek/core/singleton_method_context_spec.rb +12 -2
- data/spec/reek/core/smell_configuration_spec.rb +1 -1
- data/spec/reek/core/smell_repository_spec.rb +12 -1
- data/spec/reek/core/stop_context_spec.rb +1 -1
- data/spec/reek/core/tree_dresser_spec.rb +16 -0
- data/spec/reek/core/tree_walker_spec.rb +3 -3
- data/spec/reek/core/warning_collector_spec.rb +6 -6
- data/spec/reek/{source → sexp}/sexp_extensions_spec.rb +8 -8
- data/spec/reek/{source → sexp}/sexp_formatter_spec.rb +11 -5
- data/spec/reek/{source → sexp}/sexp_node_spec.rb +3 -3
- data/spec/reek/smells/attribute_spec.rb +89 -85
- data/spec/reek/smells/behaves_like_variable_detector.rb +1 -1
- data/spec/reek/smells/boolean_parameter_spec.rb +1 -1
- data/spec/reek/smells/class_variable_spec.rb +1 -1
- data/spec/reek/smells/control_parameter_spec.rb +1 -1
- data/spec/reek/smells/data_clump_spec.rb +2 -2
- data/spec/reek/smells/duplicate_method_call_spec.rb +1 -1
- data/spec/reek/smells/feature_envy_spec.rb +2 -2
- data/spec/reek/smells/irresponsible_module_spec.rb +1 -1
- data/spec/reek/smells/long_parameter_list_spec.rb +2 -2
- data/spec/reek/smells/long_yield_list_spec.rb +1 -1
- data/spec/reek/smells/module_initialize_spec.rb +1 -1
- data/spec/reek/smells/nested_iterators_spec.rb +2 -2
- data/spec/reek/smells/nil_check_spec.rb +1 -1
- data/spec/reek/smells/prima_donna_method_spec.rb +1 -1
- data/spec/reek/smells/repeated_conditional_spec.rb +1 -1
- data/spec/reek/smells/smell_detector_shared.rb +2 -2
- data/spec/reek/{smell_warning_spec.rb → smells/smell_warning_spec.rb} +7 -7
- data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
- data/spec/reek/smells/too_many_methods_spec.rb +1 -1
- data/spec/reek/smells/too_many_statements_spec.rb +4 -4
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +1 -1
- data/spec/reek/smells/unused_parameters_spec.rb +1 -1
- data/spec/reek/smells/utility_function_spec.rb +1 -1
- data/spec/reek/source/source_code_spec.rb +1 -1
- data/spec/reek/spec/should_reek_of_spec.rb +1 -1
- data/spec/reek/spec/should_reek_only_of_spec.rb +1 -1
- data/spec/reek/spec/should_reek_spec.rb +1 -1
- data/spec/samples/checkstyle.xml +2 -0
- data/spec/spec_helper.rb +15 -3
- metadata +68 -38
- data/.ruby-gemset +0 -1
- data/lib/reek/examiner.rb +0 -79
- data/lib/reek/smell_warning.rb +0 -87
- 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/spec/reek/source/tree_dresser_spec.rb +0 -16
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative 'smell_detector'
|
2
|
-
require_relative '../smell_warning'
|
3
2
|
|
4
3
|
module Reek
|
5
4
|
module Smells
|
@@ -10,6 +9,7 @@ module Reek
|
|
10
9
|
# +TooManyInstanceVariables' reports classes having more than a
|
11
10
|
# configurable number of instance variables.
|
12
11
|
#
|
12
|
+
# See docs/Too-Many-Instance-Variables for details.
|
13
13
|
class TooManyInstanceVariables < SmellDetector
|
14
14
|
# The name of the config field that sets the maximum number of instance
|
15
15
|
# variables permitted in a class.
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative 'smell_detector'
|
2
|
-
require_relative '../smell_warning'
|
3
2
|
|
4
3
|
module Reek
|
5
4
|
module Smells
|
@@ -12,6 +11,7 @@ module Reek
|
|
12
11
|
# methods, and excludes methods inherited from superclasses or included
|
13
12
|
# modules.
|
14
13
|
#
|
14
|
+
# See docs/Too-Many-Methods for details.
|
15
15
|
class TooManyMethods < SmellDetector
|
16
16
|
# The name of the config field that sets the maximum number of methods
|
17
17
|
# permitted in a class.
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative 'smell_detector'
|
2
|
-
require_relative '../smell_warning'
|
3
2
|
|
4
3
|
module Reek
|
5
4
|
module Smells
|
@@ -8,6 +7,7 @@ module Reek
|
|
8
7
|
#
|
9
8
|
# +TooManyStatements+ reports any method with more than 5 statements.
|
10
9
|
#
|
10
|
+
# See docs/Too-Many-Statements for details.
|
11
11
|
class TooManyStatements < SmellDetector
|
12
12
|
# The name of the config field that sets the maximum number of
|
13
13
|
# statements permitted in any method.
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative 'smell_detector'
|
2
|
-
require_relative '../smell_warning'
|
3
2
|
|
4
3
|
module Reek
|
5
4
|
module Smells
|
@@ -16,6 +15,7 @@ module Reek
|
|
16
15
|
# * 1-character names
|
17
16
|
# * names ending with a number
|
18
17
|
#
|
18
|
+
# See docs/Uncommunicative-Method-Name for details.
|
19
19
|
class UncommunicativeMethodName < SmellDetector
|
20
20
|
# The name of the config field that lists the regexps of
|
21
21
|
# smelly names to be reported.
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative 'smell_detector'
|
2
|
-
require_relative '../smell_warning'
|
3
2
|
|
4
3
|
module Reek
|
5
4
|
module Smells
|
@@ -16,6 +15,7 @@ module Reek
|
|
16
15
|
# * 1-character names
|
17
16
|
# * names ending with a number
|
18
17
|
#
|
18
|
+
# See docs/Uncommunicative-Module-Name for details.
|
19
19
|
class UncommunicativeModuleName < SmellDetector
|
20
20
|
# The name of the config field that lists the regexps of
|
21
21
|
# smelly names to be reported.
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative 'smell_detector'
|
2
|
-
require_relative '../smell_warning'
|
3
2
|
|
4
3
|
module Reek
|
5
4
|
module Smells
|
@@ -16,6 +15,7 @@ module Reek
|
|
16
15
|
# * 1-character names
|
17
16
|
# * names ending with a number
|
18
17
|
#
|
18
|
+
# See docs/Uncommunicative-Parameter-Name for details.
|
19
19
|
class UncommunicativeParameterName < SmellDetector
|
20
20
|
# The name of the config field that lists the regexps of
|
21
21
|
# smelly names to be reported.
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative 'smell_detector'
|
2
|
-
require_relative '../smell_warning'
|
3
2
|
|
4
3
|
module Reek
|
5
4
|
module Smells
|
@@ -16,6 +15,7 @@ module Reek
|
|
16
15
|
# * 1-character names
|
17
16
|
# * names ending with a number
|
18
17
|
#
|
18
|
+
# See docs/Uncommunicative-Variable-Name for details.
|
19
19
|
class UncommunicativeVariableName < SmellDetector
|
20
20
|
# The name of the config field that lists the regexps of
|
21
21
|
# smelly names to be reported.
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require_relative 'smell_detector'
|
2
|
-
require_relative '../smell_warning'
|
3
2
|
|
4
3
|
module Reek
|
5
4
|
module Smells
|
6
5
|
#
|
7
6
|
# Methods should use their parameters.
|
8
7
|
#
|
8
|
+
# See docs/Unused-Parameters for details.
|
9
9
|
class UnusedParameters < SmellDetector
|
10
10
|
def self.smell_category
|
11
11
|
'UnusedCode'
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require_relative 'smell_detector'
|
2
|
-
require_relative '../
|
3
|
-
require_relative '../source/reference_collector'
|
2
|
+
require_relative '../core/reference_collector'
|
4
3
|
|
5
4
|
module Reek
|
6
5
|
module Smells
|
@@ -35,14 +34,8 @@ module Reek
|
|
35
34
|
# If the method does refer to self, but refers to some other object more,
|
36
35
|
# +FeatureEnvy+ is reported instead.
|
37
36
|
#
|
37
|
+
# See docs/Utility-Function for details.
|
38
38
|
class UtilityFunction < SmellDetector
|
39
|
-
# The name of the config field that sets the maximum number of
|
40
|
-
# calls permitted within a helper method. Any method with more than
|
41
|
-
# this number of method calls on other objects will be considered a
|
42
|
-
# candidate Utility Function.
|
43
|
-
HELPER_CALLS_LIMIT_KEY = 'max_helper_calls'
|
44
|
-
DEFAULT_HELPER_CALLS_LIMIT = 0
|
45
|
-
|
46
39
|
def self.smell_category
|
47
40
|
'LowCohesion'
|
48
41
|
end
|
@@ -51,10 +44,6 @@ module Reek
|
|
51
44
|
def contexts # :nodoc:
|
52
45
|
[:def]
|
53
46
|
end
|
54
|
-
|
55
|
-
def default_config
|
56
|
-
super.merge(HELPER_CALLS_LIMIT_KEY => DEFAULT_HELPER_CALLS_LIMIT)
|
57
|
-
end
|
58
47
|
end
|
59
48
|
|
60
49
|
#
|
@@ -65,9 +54,7 @@ module Reek
|
|
65
54
|
def examine_context(method_ctx)
|
66
55
|
return [] if method_ctx.num_statements == 0
|
67
56
|
return [] if method_ctx.references_self?
|
68
|
-
return [] if num_helper_methods(method_ctx)
|
69
|
-
method_ctx,
|
70
|
-
DEFAULT_HELPER_CALLS_LIMIT)
|
57
|
+
return [] if num_helper_methods(method_ctx).zero?
|
71
58
|
|
72
59
|
[SmellWarning.new(self,
|
73
60
|
context: method_ctx.full_name,
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
require_relative '
|
1
|
+
require_relative '../cli/silencer'
|
2
|
+
Reek::CLI::Silencer.silently do
|
3
|
+
require 'parser/current'
|
4
|
+
end
|
5
|
+
require_relative '../core/tree_dresser'
|
6
|
+
require_relative '../core/ast_node'
|
6
7
|
|
7
8
|
module Reek
|
8
9
|
module Source
|
@@ -10,14 +11,28 @@ module Reek
|
|
10
11
|
# A +Source+ object represents a chunk of Ruby source code.
|
11
12
|
#
|
12
13
|
class SourceCode
|
13
|
-
attr_reader :
|
14
|
+
attr_reader :description
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
# Initializer.
|
17
|
+
#
|
18
|
+
# code - ruby code as String
|
19
|
+
# description - in case of STDIN this is "STDIN" otherwise it's a filepath as String
|
20
|
+
# parser - the parser to use for generating AST's out of the given source
|
21
|
+
def initialize(code, description, parser = Parser::Ruby21)
|
22
|
+
@source = code
|
23
|
+
@description = description
|
24
|
+
@parser = parser
|
19
25
|
end
|
20
26
|
|
27
|
+
# Initializes an instance of SourceCode given a source.
|
28
|
+
# This source can come via 3 different ways:
|
29
|
+
# - from files a la `reek lib/reek/`
|
30
|
+
# - from IO (STDIN) a la `echo "class Foo; end" | reek`
|
31
|
+
# - from String via our rspec matchers a la `expect("class Foo; end").to reek`
|
32
|
+
#
|
33
|
+
# source - One of File|IO|String
|
34
|
+
#
|
35
|
+
# Returns an instance of SourceCode
|
21
36
|
def self.from(source)
|
22
37
|
case source
|
23
38
|
when File then new(source.read, source.path)
|
@@ -26,17 +41,20 @@ module Reek
|
|
26
41
|
end
|
27
42
|
end
|
28
43
|
|
44
|
+
# Parses the given source into an AST.
|
45
|
+
#
|
46
|
+
# @return [Reek::Core::ASTNode] the AST presentation of the given source
|
29
47
|
def syntax_tree
|
30
48
|
@syntax_tree ||=
|
31
49
|
begin
|
32
50
|
begin
|
33
|
-
ast, comments = @parser.parse_with_comments(@source, @
|
51
|
+
ast, comments = @parser.parse_with_comments(@source, @description)
|
34
52
|
rescue Racc::ParseError, Parser::SyntaxError => error
|
35
|
-
$stderr.puts "#{
|
53
|
+
$stderr.puts "#{description}: #{error.class.name}: #{error}"
|
36
54
|
end
|
37
55
|
|
38
56
|
comment_map = Parser::Source::Comment.associate(ast, comments) if ast
|
39
|
-
TreeDresser.new.dress(ast, comment_map)
|
57
|
+
Core::TreeDresser.new.dress(ast, comment_map)
|
40
58
|
end
|
41
59
|
end
|
42
60
|
end
|
@@ -4,36 +4,35 @@ module Reek
|
|
4
4
|
# Finds Ruby source files in a filesystem.
|
5
5
|
#
|
6
6
|
class SourceLocator
|
7
|
+
# Initialize with the paths we want to search.
|
8
|
+
#
|
9
|
+
# paths - a list of paths as Strings
|
7
10
|
def initialize(paths)
|
8
11
|
@paths = paths.map { |path| path.chomp('/') }
|
9
12
|
end
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
# Traverses all paths we initialized the SourceLocator with, finds
|
15
|
+
# all relevant ruby files and returns them as a list.
|
16
|
+
#
|
17
|
+
# Returns a list of Source::SourceCode.
|
18
|
+
def sources
|
19
|
+
find_sources.map { |pathname| Source::SourceCode.from File.new(pathname) }
|
13
20
|
end
|
14
21
|
|
15
22
|
private
|
16
23
|
|
17
|
-
def
|
24
|
+
def find_sources(paths = @paths)
|
18
25
|
paths.map do |path|
|
19
|
-
|
20
|
-
|
26
|
+
pathname = Pathname.new(path)
|
27
|
+
if pathname.directory?
|
28
|
+
find_sources(Dir["#{pathname}/**/*.rb"])
|
21
29
|
else
|
22
|
-
|
30
|
+
next pathname if pathname.file?
|
31
|
+
$stderr.puts "Error: No such file - #{pathname}"
|
32
|
+
nil
|
23
33
|
end
|
24
34
|
end.flatten.sort
|
25
35
|
end
|
26
|
-
|
27
|
-
def valid_paths
|
28
|
-
all_ruby_source_files(@paths).select do |path|
|
29
|
-
if test 'f', path
|
30
|
-
true
|
31
|
-
else
|
32
|
-
$stderr.puts "Error: No such file - #{path}"
|
33
|
-
false
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
@@ -9,6 +9,13 @@ module Reek
|
|
9
9
|
# single unit of Ruby source code.
|
10
10
|
#
|
11
11
|
class SourceRepository
|
12
|
+
attr_reader :description
|
13
|
+
|
14
|
+
def initialize(description, sources)
|
15
|
+
@description = description
|
16
|
+
@sources = sources
|
17
|
+
end
|
18
|
+
|
12
19
|
# TODO: This method is a least partially broken.
|
13
20
|
# Regardless of how you call reek, be it:
|
14
21
|
# reek lib/
|
@@ -19,23 +26,15 @@ module Reek
|
|
19
26
|
def self.parse(source)
|
20
27
|
case source
|
21
28
|
when Array
|
22
|
-
new 'dir', Source::SourceLocator.new(source).
|
29
|
+
new 'dir', Source::SourceLocator.new(source).sources
|
23
30
|
when Source::SourceCode
|
24
|
-
new source.
|
31
|
+
new source.description, [source]
|
25
32
|
else
|
26
33
|
src = Source::SourceCode.from source
|
27
|
-
new src.
|
34
|
+
new src.description, [src]
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
31
|
-
include Enumerable
|
32
|
-
attr_reader :description
|
33
|
-
|
34
|
-
def initialize(description, sources)
|
35
|
-
@description = description
|
36
|
-
@sources = sources
|
37
|
-
end
|
38
|
-
|
39
38
|
def each(&block)
|
40
39
|
@sources.each(&block)
|
41
40
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '../examiner'
|
1
|
+
require_relative '../core/examiner'
|
2
2
|
require_relative '../cli/report/formatter'
|
3
3
|
|
4
4
|
module Reek
|
@@ -8,7 +8,7 @@ module Reek
|
|
8
8
|
#
|
9
9
|
class ShouldReek # :nodoc:
|
10
10
|
def matches?(actual)
|
11
|
-
@examiner = Examiner.new(actual)
|
11
|
+
@examiner = Core::Examiner.new(actual)
|
12
12
|
@examiner.smelly?
|
13
13
|
end
|
14
14
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '../examiner'
|
1
|
+
require_relative '../core/examiner'
|
2
2
|
|
3
3
|
module Reek
|
4
4
|
module Spec
|
@@ -13,7 +13,7 @@ module Reek
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def matches?(actual)
|
16
|
-
@examiner = Examiner.new(actual)
|
16
|
+
@examiner = Core::Examiner.new(actual)
|
17
17
|
@all_smells = @examiner.smells
|
18
18
|
@all_smells.any? { |warning| warning.matches?(@smell_category, @smell_details) }
|
19
19
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '../examiner'
|
1
|
+
require_relative '../core/examiner'
|
2
2
|
require_relative '../cli/report/formatter'
|
3
3
|
|
4
4
|
module Reek
|
@@ -9,7 +9,7 @@ module Reek
|
|
9
9
|
#
|
10
10
|
class ShouldReekOnlyOf < ShouldReekOf
|
11
11
|
def matches?(actual)
|
12
|
-
matches_examiner?(Examiner.new(actual))
|
12
|
+
matches_examiner?(Core::Examiner.new(actual))
|
13
13
|
end
|
14
14
|
|
15
15
|
def matches_examiner?(examiner)
|
data/lib/reek/version.rb
CHANGED
data/reek.gemspec
CHANGED
@@ -22,10 +22,9 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.required_ruby_version = '>= 1.9.3'
|
23
23
|
s.summary = 'Code smell detector for Ruby'
|
24
24
|
|
25
|
-
s.add_runtime_dependency 'parser',
|
26
|
-
s.add_runtime_dependency 'rainbow',
|
27
|
-
s.add_runtime_dependency '
|
28
|
-
s.add_runtime_dependency 'unparser', '~> 0.2.2'
|
25
|
+
s.add_runtime_dependency 'parser', '~> 2.2'
|
26
|
+
s.add_runtime_dependency 'rainbow', '~> 2.0'
|
27
|
+
s.add_runtime_dependency 'unparser', '~> 0.2.2'
|
29
28
|
|
30
29
|
s.add_development_dependency 'activesupport', '~> 4.2'
|
31
30
|
s.add_development_dependency 'aruba', '~> 0.6.2'
|
data/spec/factories/factories.rb
CHANGED
data/spec/gem/yard_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_relative '../../../lib/reek/examiner'
|
2
|
+
require_relative '../../../lib/reek/core/examiner'
|
3
3
|
require_relative '../../../lib/reek/cli/report/report'
|
4
4
|
|
5
|
-
describe Reek::CLI::Report::HTMLReport do
|
5
|
+
RSpec.describe Reek::CLI::Report::HTMLReport do
|
6
6
|
let(:instance) { Reek::CLI::Report::HTMLReport.new }
|
7
7
|
|
8
8
|
context 'with an empty source' do
|
9
|
-
let(:examiner) { Reek::Examiner.new('') }
|
9
|
+
let(:examiner) { Reek::Core::Examiner.new('') }
|
10
10
|
|
11
11
|
before do
|
12
12
|
instance.add_examiner examiner
|