reek 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/README.md +4 -4
- data/bin/reek +1 -1
- data/features/command_line_interface/options.feature +6 -6
- data/lib/reek/cli/application.rb +1 -1
- data/lib/reek/cli/options.rb +6 -6
- data/lib/reek/cli/report/formatter.rb +5 -4
- data/lib/reek/cli/report/report.rb +10 -10
- data/lib/reek/configuration/app_configuration.rb +1 -1
- data/lib/reek/configuration/configuration_file_finder.rb +1 -1
- data/lib/reek/core/method_context.rb +2 -2
- data/lib/reek/rake/task.rb +1 -1
- data/lib/reek/smell_warning.rb +4 -1
- data/lib/reek/smells/feature_envy.rb +1 -1
- data/lib/reek/source/sexp_extensions.rb +13 -2
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +1 -1
- data/spec/reek/smells/feature_envy_spec.rb +2 -0
- data/spec/reek/smells/nested_iterators_spec.rb +24 -17
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6f9a08539415ceecd74495e36b1a11235bfccf2
|
4
|
+
data.tar.gz: aa9edb39c1cae7f4c66e2ac41e7173b39f337b4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b7743dfb2ca76846caae26697fe43ad25d0721e8a135286abd4918e2a541cfed814f81a4ef128e4c9547023091332d8b8c406a3ce247e1a58b0fe181cbf09d3
|
7
|
+
data.tar.gz: 41f70992cd0209073947a48151b2a2da3bc83017576bf1b25f53b849100f6b1e2d2458fa18ed6b65929c8e0b3d69ab5a37d48d1ed9a51259d9f458d53e88df4c
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 2.0.3
|
2
|
+
|
3
|
+
* (mvz) Make NestedIterators handle super with arguments
|
4
|
+
* (mvz) Handle shadow block arguments
|
5
|
+
* (CoralineAda) Allow all formatters to support -U (wiki links)
|
6
|
+
* (tuexss) Make defaults transparent in help message
|
7
|
+
|
1
8
|
== 2.0.2
|
2
9
|
|
3
10
|
* (troessner) Fix version command
|
data/README.md
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
## Overview
|
4
4
|
|
5
5
|
|
6
|
-
[![Build Status](https://secure.travis-ci.org/troessner/reek.png?branch=master)](
|
7
|
-
[![Gem Version](https://badge.fury.io/rb/reek.png)](
|
6
|
+
[![Build Status](https://secure.travis-ci.org/troessner/reek.png?branch=master)](https://travis-ci.org/troessner/reek?branch=master)
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/reek.png)](https://badge.fury.io/rb/reek)
|
8
8
|
[![Dependency Status](https://gemnasium.com/troessner/reek.png)](https://gemnasium.com/troessner/reek)
|
9
|
-
[![Inline docs](
|
9
|
+
[![Inline docs](https://inch-ci.org/github/troessner/reek.png)](https://inch-ci.org/github/troessner/reek)
|
10
10
|
|
11
11
|
## Quickstart
|
12
12
|
|
@@ -228,7 +228,7 @@ Colorful output for `reek`: [Preek](https://github.com/joenas/preek) (also with
|
|
228
228
|
|
229
229
|
### Find out more:
|
230
230
|
|
231
|
-
* [Stack Overflow](
|
231
|
+
* [Stack Overflow](https://stackoverflow.com/questions/tagged/reek)
|
232
232
|
* [RDoc](http://rdoc.info/projects/troessner/reek)
|
233
233
|
|
234
234
|
## Contributors
|
data/bin/reek
CHANGED
@@ -27,11 +27,11 @@ Feature: Reek can be controlled using command-line options
|
|
27
27
|
reek -s lib
|
28
28
|
cat my_class.rb | reek
|
29
29
|
|
30
|
-
See
|
30
|
+
See https://wiki.github.com/troessner/reek for detailed help.
|
31
31
|
|
32
32
|
Configuration:
|
33
33
|
-c, --config FILE Read configuration options from FILE
|
34
|
-
--smell SMELL Detect smell SMELL (default
|
34
|
+
--smell SMELL Detect smell SMELL (default: all enabled smells)
|
35
35
|
|
36
36
|
Report format:
|
37
37
|
-f, --format FORMAT Report smells in the given format:
|
@@ -41,10 +41,10 @@ Feature: Reek can be controlled using command-line options
|
|
41
41
|
json
|
42
42
|
|
43
43
|
Text format options:
|
44
|
-
--[no-]color Use colors for the output (
|
45
|
-
-V, --[no-]empty-headings Show headings for smell-free source files
|
46
|
-
-U, --[no-]wiki-links Show link to related
|
47
|
-
-n, --[no-]line-numbers Show line numbers in the output (
|
44
|
+
--[no-]color Use colors for the output (default: true)
|
45
|
+
-V, --[no-]empty-headings Show headings for smell-free source files (default: false)
|
46
|
+
-U, --[no-]wiki-links Show link to related wiki page for each smell (default: false)
|
47
|
+
-n, --[no-]line-numbers Show line numbers in the output (default: true)
|
48
48
|
-s, --single-line Show location in editor-compatible single-line-per-smell format
|
49
49
|
--sort-by SORTING Sort reported files by the given criterium:
|
50
50
|
smelliness ("smelliest" files first)
|
data/lib/reek/cli/application.rb
CHANGED
data/lib/reek/cli/options.rb
CHANGED
@@ -45,7 +45,7 @@ module Reek
|
|
45
45
|
#{program_name} -s lib
|
46
46
|
cat my_class.rb | #{program_name}
|
47
47
|
|
48
|
-
See
|
48
|
+
See https://wiki.github.com/troessner/reek for detailed help.
|
49
49
|
|
50
50
|
EOB
|
51
51
|
end
|
@@ -66,7 +66,7 @@ module Reek
|
|
66
66
|
@parser.on('-c', '--config FILE', 'Read configuration options from FILE') do |file|
|
67
67
|
@options.config_file = file
|
68
68
|
end
|
69
|
-
@parser.on('--smell SMELL', 'Detect smell SMELL (default
|
69
|
+
@parser.on('--smell SMELL', 'Detect smell SMELL (default: all enabled smells)') do |smell|
|
70
70
|
@options.smells_to_detect << smell
|
71
71
|
end
|
72
72
|
end
|
@@ -80,25 +80,25 @@ module Reek
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def set_up_color_option
|
83
|
-
@parser.on('--[no-]color', 'Use colors for the output (
|
83
|
+
@parser.on('--[no-]color', 'Use colors for the output (default: true)') do |opt|
|
84
84
|
@options.colored = opt
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
def set_up_verbosity_options
|
89
89
|
@parser.on('-V', '--[no-]empty-headings',
|
90
|
-
'Show headings for smell-free source files') do |show_empty|
|
90
|
+
'Show headings for smell-free source files (default: false)') do |show_empty|
|
91
91
|
@options.show_empty = show_empty
|
92
92
|
end
|
93
93
|
@parser.on('-U', '--[no-]wiki-links',
|
94
|
-
'Show link to related
|
94
|
+
'Show link to related wiki page for each smell (default: false)') do |show_links|
|
95
95
|
@options.show_links = show_links
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
def set_up_location_formatting_options
|
100
100
|
@parser.on('-n', '--[no-]line-numbers',
|
101
|
-
'Show line numbers in the output (
|
101
|
+
'Show line numbers in the output (default: true)') do |show_numbers|
|
102
102
|
@options.location_format = show_numbers ? :numbers : :plain
|
103
103
|
end
|
104
104
|
@parser.on('-s', '--single-line',
|
@@ -4,8 +4,9 @@ module Reek
|
|
4
4
|
module Cli
|
5
5
|
module Report
|
6
6
|
#
|
7
|
-
# Formatter handling the formatting of the report at large.
|
8
|
-
# the individual warnings is handled by the
|
7
|
+
# Formatter handling the formatting of the report at large.
|
8
|
+
# Formatting of the individual warnings is handled by the
|
9
|
+
# passed-in warning formatter.
|
9
10
|
#
|
10
11
|
module Formatter
|
11
12
|
def self.format_list(warnings, formatter = SimpleWarningFormatter.new)
|
@@ -25,7 +26,7 @@ module Reek
|
|
25
26
|
|
26
27
|
#
|
27
28
|
# Basic formatter that just shows a simple message for each warning,
|
28
|
-
#
|
29
|
+
# prepended with the result of the passed-in location formatter.
|
29
30
|
#
|
30
31
|
class SimpleWarningFormatter
|
31
32
|
def initialize(location_formatter = BlankLocationFormatter)
|
@@ -44,7 +45,7 @@ module Reek
|
|
44
45
|
end
|
45
46
|
|
46
47
|
#
|
47
|
-
# Formatter that adds a link to the
|
48
|
+
# Formatter that adds a link to the wiki to the basic message from
|
48
49
|
# SimpleWarningFormatter.
|
49
50
|
#
|
50
51
|
class WikiLinkWarningFormatter < SimpleWarningFormatter
|
@@ -12,9 +12,13 @@ module Reek
|
|
12
12
|
NO_WARNINGS_COLOR = :green
|
13
13
|
WARNINGS_COLOR = :red
|
14
14
|
|
15
|
-
def initialize(
|
15
|
+
def initialize(options = {})
|
16
16
|
@examiners = []
|
17
17
|
@total_smell_count = 0
|
18
|
+
@options = options
|
19
|
+
@warning_formatter = options.fetch :warning_formatter, SimpleWarningFormatter.new
|
20
|
+
@report_formatter = options.fetch :report_formatter, Formatter
|
21
|
+
@sort_by_issue_count = options.fetch :sort_by_issue_count, false
|
18
22
|
end
|
19
23
|
|
20
24
|
def add_examiner(examiner)
|
@@ -36,14 +40,6 @@ module Reek
|
|
36
40
|
# Generates a sorted, text summary of smells in examiners
|
37
41
|
#
|
38
42
|
class TextReport < Base
|
39
|
-
def initialize(options = {})
|
40
|
-
super options
|
41
|
-
@options = options
|
42
|
-
@warning_formatter = options.fetch :warning_formatter, SimpleWarningFormatter.new
|
43
|
-
@report_formatter = options.fetch :report_formatter, Formatter
|
44
|
-
@sort_by_issue_count = options.fetch :sort_by_issue_count, false
|
45
|
-
end
|
46
|
-
|
47
43
|
def show
|
48
44
|
sort_examiners if smells?
|
49
45
|
display_summary
|
@@ -107,7 +103,11 @@ module Reek
|
|
107
103
|
# JSON with empty array for 0 smells
|
108
104
|
class JsonReport < Base
|
109
105
|
def show
|
110
|
-
print ::JSON.generate(
|
106
|
+
print ::JSON.generate(
|
107
|
+
smells.map do |smell|
|
108
|
+
smell.yaml_hash(@warning_formatter)
|
109
|
+
end
|
110
|
+
)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -3,7 +3,7 @@ require 'pathname'
|
|
3
3
|
module Reek
|
4
4
|
module Configuration
|
5
5
|
#
|
6
|
-
# ConfigurationFileFinder is responsible for finding
|
6
|
+
# ConfigurationFileFinder is responsible for finding reek's configuration.
|
7
7
|
#
|
8
8
|
# There are 3 ways of passing `reek` a configuration file:
|
9
9
|
# 1. Using the cli "-c" switch
|
@@ -41,9 +41,9 @@ module Reek
|
|
41
41
|
receiver ||= [:self]
|
42
42
|
case receiver[0]
|
43
43
|
when :lvasgn
|
44
|
-
@refs.record_reference_to(receiver.
|
44
|
+
@refs.record_reference_to(receiver.name)
|
45
45
|
when :lvar
|
46
|
-
@refs.record_reference_to(receiver) unless meth == :new
|
46
|
+
@refs.record_reference_to(receiver.name) unless meth == :new
|
47
47
|
when :self
|
48
48
|
@refs.record_reference_to(:self)
|
49
49
|
end
|
data/lib/reek/rake/task.rb
CHANGED
data/lib/reek/smell_warning.rb
CHANGED
@@ -42,7 +42,7 @@ module Reek
|
|
42
42
|
listener.found_smell(self)
|
43
43
|
end
|
44
44
|
|
45
|
-
def yaml_hash
|
45
|
+
def yaml_hash(warning_formatter = nil)
|
46
46
|
result = {
|
47
47
|
'smell_category' => smell_detector.smell_category,
|
48
48
|
'smell_type' => smell_detector.smell_type,
|
@@ -51,6 +51,9 @@ module Reek
|
|
51
51
|
'lines' => lines,
|
52
52
|
'message' => message
|
53
53
|
}
|
54
|
+
if warning_formatter.respond_to?(:explanatory_link)
|
55
|
+
result.merge!('wiki_link' => warning_formatter.explanatory_link(smell_detector))
|
56
|
+
end
|
54
57
|
parameters.each do |key, value|
|
55
58
|
result[key.to_s] = value
|
56
59
|
end
|
@@ -91,6 +91,11 @@ module Reek
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
# Utility methods for :shadowarg nodes.
|
95
|
+
module ShadowargNode
|
96
|
+
include ArgNodeBase
|
97
|
+
end
|
98
|
+
|
94
99
|
# Base module for utility methods for :and and :or nodes.
|
95
100
|
module LogicOperatorBase
|
96
101
|
def condition() self[1] end
|
@@ -179,9 +184,13 @@ module Reek
|
|
179
184
|
|
180
185
|
# Utility methods for :lvar nodes.
|
181
186
|
module LvarNode
|
187
|
+
include VariableBase
|
188
|
+
# TODO: Replace with name().
|
182
189
|
def var_name() self[1] end
|
183
190
|
end
|
184
191
|
|
192
|
+
LvasgnNode = LvarNode
|
193
|
+
|
185
194
|
# Base module for utility methods for :def and :defs nodes.
|
186
195
|
module MethodNodeBase
|
187
196
|
def arguments
|
@@ -315,12 +324,14 @@ module Reek
|
|
315
324
|
end
|
316
325
|
end
|
317
326
|
|
318
|
-
# Utility methods for :
|
319
|
-
module
|
327
|
+
# Utility methods for :super nodes.
|
328
|
+
module SuperNode
|
320
329
|
def method_name
|
321
330
|
:super
|
322
331
|
end
|
323
332
|
end
|
333
|
+
|
334
|
+
ZsuperNode = SuperNode
|
324
335
|
end
|
325
336
|
end
|
326
337
|
end
|
data/lib/reek/version.rb
CHANGED
data/reek.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
'Rakefile', 'assets/html_output.html.erb', 'bin/reek',
|
22
22
|
'config/defaults.reek', '{features,lib,spec,tasks}/**/*',
|
23
23
|
'reek.gemspec'] & `git ls-files -z`.split("\0")
|
24
|
-
s.homepage = '
|
24
|
+
s.homepage = 'https://wiki.github.com/troessner/reek'
|
25
25
|
s.rdoc_options = ['--main', 'README.md',
|
26
26
|
'-x', 'assets/|bin/|config/|features/|spec/|tasks/']
|
27
27
|
s.require_paths = ['lib']
|
@@ -138,6 +138,7 @@ describe Reek::Smells::FeatureEnvy do
|
|
138
138
|
it 'counts =~ as a call' do
|
139
139
|
src = <<-EOS
|
140
140
|
def foo arg
|
141
|
+
bar(arg.baz)
|
141
142
|
arg =~ /bar/
|
142
143
|
end
|
143
144
|
EOS
|
@@ -147,6 +148,7 @@ describe Reek::Smells::FeatureEnvy do
|
|
147
148
|
it 'counts += as a call' do
|
148
149
|
src = <<-EOS
|
149
150
|
def foo arg
|
151
|
+
bar(arg.baz)
|
150
152
|
arg += 1
|
151
153
|
end
|
152
154
|
EOS
|
@@ -98,6 +98,30 @@ describe Reek::Smells::NestedIterators do
|
|
98
98
|
expect(src).to reek_of(:NestedIterators, count: 3)
|
99
99
|
end
|
100
100
|
|
101
|
+
it 'handles the case where super recieves a block' do
|
102
|
+
src = <<-EOS
|
103
|
+
def super_call_with_block
|
104
|
+
super do |k|
|
105
|
+
nothing.each { |thing| item }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
EOS
|
109
|
+
|
110
|
+
expect(src).to reek_of(:NestedIterators)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'handles the case where super recieves a block and arguments' do
|
114
|
+
src = <<-EOS
|
115
|
+
def super_call_with_block
|
116
|
+
super(foo) do |k|
|
117
|
+
nothing.each { |thing| item }
|
118
|
+
end
|
119
|
+
end
|
120
|
+
EOS
|
121
|
+
|
122
|
+
expect(src).to reek_of(:NestedIterators)
|
123
|
+
end
|
124
|
+
|
101
125
|
context 'when the allowed nesting depth is 3' do
|
102
126
|
before :each do
|
103
127
|
@config = { NestedIterators:
|
@@ -224,21 +248,4 @@ describe Reek::Smells::NestedIterators do
|
|
224
248
|
expect(@warning.lines).to eq([3])
|
225
249
|
end
|
226
250
|
end
|
227
|
-
|
228
|
-
context 'super recieves a block' do
|
229
|
-
before :each do
|
230
|
-
src = <<-EOS
|
231
|
-
def super_call_with_block
|
232
|
-
super do |k|
|
233
|
-
nothing.each { |thing| item }
|
234
|
-
end
|
235
|
-
end
|
236
|
-
EOS
|
237
|
-
|
238
|
-
ctx = Reek::Core::CodeContext.new(nil, src.to_reek_source.syntax_tree)
|
239
|
-
@warning = @detector.examine_context(ctx)[0]
|
240
|
-
end
|
241
|
-
|
242
|
-
it_should_behave_like 'common fields set correctly'
|
243
|
-
end
|
244
251
|
end
|
@@ -140,6 +140,16 @@ describe Reek::Smells::UncommunicativeVariableName do
|
|
140
140
|
expect(src).to reek_of(:UncommunicativeVariableName, name: 'y')
|
141
141
|
expect(src).to reek_of(:UncommunicativeVariableName, name: 'z')
|
142
142
|
end
|
143
|
+
|
144
|
+
it 'reports shadowed block parameters' do
|
145
|
+
src = <<-EOS
|
146
|
+
def bad
|
147
|
+
@foo.map { |x; y| y = x * 2 }
|
148
|
+
end
|
149
|
+
EOS
|
150
|
+
expect(src).to reek_of(:UncommunicativeVariableName, name: 'x')
|
151
|
+
expect(src).to reek_of(:UncommunicativeVariableName, name: 'y')
|
152
|
+
end
|
143
153
|
end
|
144
154
|
|
145
155
|
context 'when a smell is reported' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Rutherford
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parser
|
@@ -411,7 +411,7 @@ files:
|
|
411
411
|
- tasks/reek.rake
|
412
412
|
- tasks/rubocop.rake
|
413
413
|
- tasks/test.rake
|
414
|
-
homepage:
|
414
|
+
homepage: https://wiki.github.com/troessner/reek
|
415
415
|
licenses:
|
416
416
|
- MIT
|
417
417
|
metadata: {}
|