reek 3.11 → 4.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +13 -1
- data/README.md +0 -1
- data/bin/code_climate_reek +1 -0
- data/bin/reek +1 -0
- data/docs/API.md +2 -2
- data/docs/RSpec-matchers.md +4 -7
- data/features/reports/json.feature +0 -4
- data/features/reports/yaml.feature +4 -8
- data/lib/reek.rb +1 -0
- data/lib/reek/ast/ast_node_class_map.rb +1 -0
- data/lib/reek/ast/node.rb +1 -0
- data/lib/reek/ast/object_refs.rb +2 -1
- data/lib/reek/ast/reference_collector.rb +1 -0
- data/lib/reek/ast/sexp_extensions.rb +1 -0
- data/lib/reek/ast/sexp_extensions/arguments.rb +1 -0
- data/lib/reek/ast/sexp_extensions/attribute_assignments.rb +1 -0
- data/lib/reek/ast/sexp_extensions/block.rb +1 -0
- data/lib/reek/ast/sexp_extensions/case.rb +1 -0
- data/lib/reek/ast/sexp_extensions/constant.rb +1 -0
- data/lib/reek/ast/sexp_extensions/if.rb +1 -0
- data/lib/reek/ast/sexp_extensions/literal.rb +1 -0
- data/lib/reek/ast/sexp_extensions/logical_operators.rb +1 -0
- data/lib/reek/ast/sexp_extensions/methods.rb +1 -0
- data/lib/reek/ast/sexp_extensions/module.rb +1 -0
- data/lib/reek/ast/sexp_extensions/nested_assignables.rb +1 -0
- data/lib/reek/ast/sexp_extensions/self.rb +1 -0
- data/lib/reek/ast/sexp_extensions/send.rb +1 -0
- data/lib/reek/ast/sexp_extensions/super.rb +1 -0
- data/lib/reek/ast/sexp_extensions/symbols.rb +1 -0
- data/lib/reek/ast/sexp_extensions/variables.rb +1 -0
- data/lib/reek/ast/sexp_extensions/when.rb +1 -0
- data/lib/reek/ast/sexp_extensions/yield.rb +1 -0
- data/lib/reek/cli/application.rb +1 -0
- data/lib/reek/cli/command/base_command.rb +1 -0
- data/lib/reek/cli/command/report_command.rb +2 -1
- data/lib/reek/cli/command/todo_list_command.rb +2 -1
- data/lib/reek/cli/input.rb +1 -0
- data/lib/reek/cli/option_interpreter.rb +1 -0
- data/lib/reek/cli/options.rb +1 -0
- data/lib/reek/cli/silencer.rb +1 -0
- data/lib/reek/cli/warning_collector.rb +1 -0
- data/lib/reek/code_comment.rb +1 -0
- data/lib/reek/configuration/app_configuration.rb +1 -0
- data/lib/reek/configuration/configuration_file_finder.rb +1 -0
- data/lib/reek/configuration/configuration_validator.rb +1 -0
- data/lib/reek/configuration/default_directive.rb +1 -0
- data/lib/reek/configuration/directory_directives.rb +1 -0
- data/lib/reek/configuration/excluded_paths.rb +1 -0
- data/lib/reek/context/attribute_context.rb +1 -0
- data/lib/reek/context/class_context.rb +1 -0
- data/lib/reek/context/code_context.rb +1 -0
- data/lib/reek/context/ghost_context.rb +1 -0
- data/lib/reek/context/method_context.rb +1 -0
- data/lib/reek/context/module_context.rb +1 -0
- data/lib/reek/context/root_context.rb +1 -0
- data/lib/reek/context/send_context.rb +1 -0
- data/lib/reek/context/singleton_attribute_context.rb +1 -0
- data/lib/reek/context/singleton_method_context.rb +1 -0
- data/lib/reek/context/statement_counter.rb +1 -0
- data/lib/reek/context/visibility_tracker.rb +3 -2
- data/lib/reek/context_builder.rb +1 -0
- data/lib/reek/examiner.rb +2 -1
- data/lib/reek/rake/task.rb +1 -0
- data/lib/reek/report.rb +1 -0
- data/lib/reek/report/code_climate/code_climate_formatter.rb +2 -2
- data/lib/reek/report/formatter.rb +1 -0
- data/lib/reek/report/heading_formatter.rb +1 -0
- data/lib/reek/report/location_formatter.rb +1 -0
- data/lib/reek/report/report.rb +3 -3
- data/lib/reek/smells.rb +1 -0
- data/lib/reek/smells/attribute.rb +1 -0
- data/lib/reek/smells/boolean_parameter.rb +1 -4
- data/lib/reek/smells/class_variable.rb +1 -0
- data/lib/reek/smells/control_parameter.rb +7 -4
- data/lib/reek/smells/data_clump.rb +1 -0
- data/lib/reek/smells/duplicate_method_call.rb +5 -4
- data/lib/reek/smells/feature_envy.rb +1 -4
- data/lib/reek/smells/irresponsible_module.rb +1 -0
- data/lib/reek/smells/long_parameter_list.rb +1 -0
- data/lib/reek/smells/long_yield_list.rb +1 -4
- data/lib/reek/smells/module_initialize.rb +1 -0
- data/lib/reek/smells/nested_iterators.rb +2 -1
- data/lib/reek/smells/nil_check.rb +3 -4
- data/lib/reek/smells/prima_donna_method.rb +1 -0
- data/lib/reek/smells/repeated_conditional.rb +1 -4
- data/lib/reek/smells/smell_configuration.rb +1 -0
- data/lib/reek/smells/smell_detector.rb +2 -13
- data/lib/reek/smells/smell_repository.rb +1 -0
- data/lib/reek/smells/smell_warning.rb +4 -6
- data/lib/reek/smells/too_many_instance_variables.rb +1 -4
- data/lib/reek/smells/too_many_methods.rb +1 -4
- data/lib/reek/smells/too_many_statements.rb +1 -4
- data/lib/reek/smells/uncommunicative_method_name.rb +2 -5
- data/lib/reek/smells/uncommunicative_module_name.rb +2 -6
- data/lib/reek/smells/uncommunicative_parameter_name.rb +3 -6
- data/lib/reek/smells/uncommunicative_variable_name.rb +1 -4
- data/lib/reek/smells/unused_parameters.rb +1 -4
- data/lib/reek/smells/unused_private_method.rb +1 -0
- data/lib/reek/smells/utility_function.rb +1 -4
- data/lib/reek/source/source_code.rb +2 -1
- data/lib/reek/source/source_locator.rb +1 -0
- data/lib/reek/spec.rb +16 -23
- data/lib/reek/spec/should_reek.rb +3 -2
- data/lib/reek/spec/should_reek_of.rb +18 -15
- data/lib/reek/spec/should_reek_only_of.rb +6 -5
- data/lib/reek/spec/smell_matcher.rb +3 -7
- data/lib/reek/tree_dresser.rb +1 -0
- data/lib/reek/version.rb +2 -1
- data/reek.gemspec +1 -1
- data/spec/reek/examiner_spec.rb +8 -4
- data/spec/reek/report/code_climate_formatter_spec.rb +1 -1
- data/spec/reek/report/code_climate_report_spec.rb +2 -2
- data/spec/reek/report/html_report_spec.rb +1 -6
- data/spec/reek/report/json_report_spec.rb +0 -4
- data/spec/reek/report/yaml_report_spec.rb +0 -4
- data/spec/reek/smells/data_clump_spec.rb +2 -2
- data/spec/reek/smells/feature_envy_spec.rb +3 -3
- data/spec/reek/smells/nested_iterators_spec.rb +0 -1
- data/spec/reek/smells/prima_donna_method_spec.rb +0 -1
- data/spec/reek/smells/smell_detector_shared.rb +1 -5
- data/spec/reek/smells/too_many_methods_spec.rb +0 -1
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +0 -1
- data/spec/reek/smells/unused_private_method_spec.rb +6 -4
- data/spec/reek/smells/utility_function_spec.rb +1 -1
- data/spec/reek/spec/should_reek_of_spec.rb +7 -3
- data/spec/reek/spec/smell_matcher_spec.rb +0 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8309582de93065645810663cbed12c501ffe0b68
|
4
|
+
data.tar.gz: 73712e80702d432edc320bb5531846d3eefcf266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bce9a189c55a37b998dbe35a353fd3ab0ec8379a7c8e058712be3d8d3d5a2c0e111375ccb1b12f2146deea7225272a4cfcfe06c2e199d3d0aa75d8450a179cc7
|
7
|
+
data.tar.gz: dc7cca14a3c083bd41ce51f6cfbbd1da3339bd70c53282fa1f1d3d73102a3f06fa5718af8c61a339bab10210e558bf626d50e315a822ae3f3168dfefb4b2ddd5
|
data/.rubocop.yml
CHANGED
@@ -3,6 +3,7 @@ AllCops:
|
|
3
3
|
- 'spec/samples/**/*'
|
4
4
|
- 'tmp/**/*'
|
5
5
|
- 'vendor/**/*'
|
6
|
+
TargetRubyVersion: 2.1
|
6
7
|
|
7
8
|
# FIXME: Make the class shorter
|
8
9
|
Metrics/ClassLength:
|
@@ -40,6 +41,13 @@ Style/DotPosition:
|
|
40
41
|
Style/EmptyLineBetweenDefs:
|
41
42
|
AllowAdjacentOneLineDefs: true
|
42
43
|
|
44
|
+
# Require comment for files in lib and bin
|
45
|
+
Style/FrozenStringLiteralComment:
|
46
|
+
Include:
|
47
|
+
- 'bin/*'
|
48
|
+
- 'lib/**/*'
|
49
|
+
EnforcedStyle: always
|
50
|
+
|
43
51
|
# Allow multiline block chains
|
44
52
|
Style/MultilineBlockChain:
|
45
53
|
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
##
|
3
|
+
## 4.0.0.pre1 (2016-03-01)
|
4
|
+
|
5
|
+
* First pre-release for Reek 4.
|
6
|
+
* (troessner) Make all optional arguments to Examiner's constructor keyword
|
7
|
+
arguments.
|
8
|
+
* (troessner) Use keyword arguments without defaults as allowed by Ruby 2.1.
|
9
|
+
* (mvz) Remove smell category concept:
|
10
|
+
- The smell category is removed from the YAML and JSON outputs.
|
11
|
+
- The smell category can no longer be used to select smells in the reek_of
|
12
|
+
matcher.
|
13
|
+
* (chastell) Make HTML report print to stdout like the other reports
|
14
|
+
* (troessner) Drop support for CRuby 2.0
|
15
|
+
* (mvz) Speed up reek_of matcher by only running the given smell
|
4
16
|
|
5
17
|
## 3.11 (2016-02-18)
|
6
18
|
|
data/README.md
CHANGED
data/bin/code_climate_reek
CHANGED
data/bin/reek
CHANGED
data/docs/API.md
CHANGED
@@ -32,7 +32,7 @@ source = <<-EOS
|
|
32
32
|
EOS
|
33
33
|
|
34
34
|
reporter = Reek::Report::TextReport.new
|
35
|
-
examiner = Reek::Examiner.new
|
35
|
+
examiner = Reek::Examiner.new source
|
36
36
|
reporter.add_examiner examiner
|
37
37
|
reporter.show
|
38
38
|
```
|
@@ -175,7 +175,7 @@ source = <<-END
|
|
175
175
|
end
|
176
176
|
END
|
177
177
|
|
178
|
-
examiner = Reek::Examiner.new
|
178
|
+
examiner = Reek::Examiner.new source
|
179
179
|
examiner.smells.each do |smell|
|
180
180
|
puts smell.message
|
181
181
|
end
|
data/docs/RSpec-matchers.md
CHANGED
@@ -71,21 +71,18 @@ See the "Quickstart" example from above.
|
|
71
71
|
|
72
72
|
### `reek_of`
|
73
73
|
|
74
|
-
Checks the target source code for instances of "smell
|
74
|
+
Checks the target source code for instances of "smell type"
|
75
75
|
and returns true only if it can find one of them that matches.
|
76
76
|
|
77
77
|
Remember that this includes our "smell types" as well. So it could be the
|
78
78
|
"smell type" UtilityFunction, which is represented as a concrete class
|
79
79
|
in Reek but it could also be "Duplication" which is a "smell categgory".
|
80
80
|
|
81
|
-
|
81
|
+
You could pass many different types of input here:
|
82
82
|
- `:UtilityFunction`
|
83
83
|
- `"UtilityFunction"`
|
84
|
-
- `UtilityFunction` (this works in our specs because we tend to do "include
|
85
|
-
Reek:Smells")
|
86
84
|
- `Reek::Smells::UtilityFunction` (the right way if you really want to pass a
|
87
85
|
class)
|
88
|
-
- `"Duplication"` or `:Duplication` which is an abstract "smell category"
|
89
86
|
|
90
87
|
It is recommended to pass this as a symbol like `:UtilityFunction`. However we
|
91
88
|
don't enforce this.
|
@@ -100,7 +97,7 @@ something that doesn't make much sense.
|
|
100
97
|
|
101
98
|
So in a nutshell `reek_of` takes the following two arguments:
|
102
99
|
|
103
|
-
- `
|
100
|
+
- `smell_type` - The "smell type" we check for.
|
104
101
|
- `smells_details` - A hash containing "smell warning" parameters
|
105
102
|
|
106
103
|
**Examples**
|
@@ -131,7 +128,7 @@ See the documentaton for `reek_of`.
|
|
131
128
|
|
132
129
|
**Notable differences to `reek_of`:**
|
133
130
|
|
134
|
-
1. `reek_of` doesn't mind if there are other smells of a different
|
131
|
+
1. `reek_of` doesn't mind if there are other smells of a different type.
|
135
132
|
"reek_only_of" will fail in that case.
|
136
133
|
|
137
134
|
2. `reek_only_of` doesn't support the additional smell_details hash.
|
@@ -19,7 +19,6 @@ Feature: Report smells using simple JSON layout
|
|
19
19
|
"""
|
20
20
|
[
|
21
21
|
{
|
22
|
-
"smell_category": "Duplication",
|
23
22
|
"smell_type": "DuplicateMethodCall",
|
24
23
|
"source": "smelly.rb",
|
25
24
|
"context": "Smelly#m",
|
@@ -30,7 +29,6 @@ Feature: Report smells using simple JSON layout
|
|
30
29
|
"count": 2
|
31
30
|
},
|
32
31
|
{
|
33
|
-
"smell_category": "Duplication",
|
34
32
|
"smell_type": "DuplicateMethodCall",
|
35
33
|
"source": "smelly.rb",
|
36
34
|
"context": "Smelly#m",
|
@@ -41,7 +39,6 @@ Feature: Report smells using simple JSON layout
|
|
41
39
|
"count": 2
|
42
40
|
},
|
43
41
|
{
|
44
|
-
"smell_category": "UncommunicativeName",
|
45
42
|
"smell_type": "UncommunicativeMethodName",
|
46
43
|
"source": "smelly.rb",
|
47
44
|
"context": "Smelly#m",
|
@@ -60,7 +57,6 @@ Feature: Report smells using simple JSON layout
|
|
60
57
|
"""
|
61
58
|
[
|
62
59
|
{
|
63
|
-
"smell_category": "IrresponsibleModule",
|
64
60
|
"smell_type": "IrresponsibleModule",
|
65
61
|
"source": "STDIN",
|
66
62
|
"context": "Turn",
|
@@ -18,8 +18,7 @@ Feature: Report smells using simple YAML layout
|
|
18
18
|
And it reports this yaml:
|
19
19
|
"""
|
20
20
|
---
|
21
|
-
-
|
22
|
-
smell_type: DuplicateMethodCall
|
21
|
+
- smell_type: DuplicateMethodCall
|
23
22
|
source: smelly.rb
|
24
23
|
context: Smelly#m
|
25
24
|
lines:
|
@@ -29,8 +28,7 @@ Feature: Report smells using simple YAML layout
|
|
29
28
|
name: "@foo.bar"
|
30
29
|
count: 2
|
31
30
|
wiki_link: https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md
|
32
|
-
-
|
33
|
-
smell_type: DuplicateMethodCall
|
31
|
+
- smell_type: DuplicateMethodCall
|
34
32
|
source: smelly.rb
|
35
33
|
context: Smelly#m
|
36
34
|
lines:
|
@@ -40,8 +38,7 @@ Feature: Report smells using simple YAML layout
|
|
40
38
|
name: puts @foo.bar
|
41
39
|
count: 2
|
42
40
|
wiki_link: https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md
|
43
|
-
-
|
44
|
-
smell_type: UncommunicativeMethodName
|
41
|
+
- smell_type: UncommunicativeMethodName
|
45
42
|
source: smelly.rb
|
46
43
|
context: Smelly#m
|
47
44
|
lines:
|
@@ -57,8 +54,7 @@ Feature: Report smells using simple YAML layout
|
|
57
54
|
And it reports this yaml:
|
58
55
|
"""
|
59
56
|
---
|
60
|
-
-
|
61
|
-
smell_type: IrresponsibleModule
|
57
|
+
- smell_type: IrresponsibleModule
|
62
58
|
source: "STDIN"
|
63
59
|
context: Turn
|
64
60
|
lines:
|
data/lib/reek.rb
CHANGED
data/lib/reek/ast/node.rb
CHANGED
data/lib/reek/ast/object_refs.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Reek
|
2
3
|
# Represents functionality related to an Abstract Syntax Tree.
|
3
4
|
module AST
|
@@ -29,7 +30,7 @@ module Reek
|
|
29
30
|
# @param line [Int] The line number where this reference occurs.
|
30
31
|
#
|
31
32
|
# @return [Int|nil] The line number that was added (which might be nil).
|
32
|
-
def record_reference(name
|
33
|
+
def record_reference(name:, line: nil)
|
33
34
|
refs[name] << line
|
34
35
|
end
|
35
36
|
|
data/lib/reek/cli/application.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'base_command'
|
2
3
|
require_relative '../../examiner'
|
3
4
|
|
@@ -20,7 +21,7 @@ module Reek
|
|
20
21
|
def populate_reporter_with_smells(app)
|
21
22
|
sources.each do |source|
|
22
23
|
reporter.add_examiner Examiner.new(source,
|
23
|
-
smell_names,
|
24
|
+
filter_by_smells: smell_names,
|
24
25
|
configuration: app.configuration)
|
25
26
|
end
|
26
27
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'base_command'
|
2
3
|
require_relative '../../examiner'
|
3
4
|
|
@@ -29,7 +30,7 @@ module Reek
|
|
29
30
|
def scan_for_smells(app)
|
30
31
|
sources.map do |source|
|
31
32
|
Examiner.new(source,
|
32
|
-
smell_names,
|
33
|
+
filter_by_smells: smell_names,
|
33
34
|
configuration: app.configuration)
|
34
35
|
end.map(&:smells).flatten
|
35
36
|
end
|
data/lib/reek/cli/input.rb
CHANGED
data/lib/reek/cli/options.rb
CHANGED
data/lib/reek/cli/silencer.rb
CHANGED