reek 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/README.md +37 -0
- data/features/configuration_loading.feature +62 -0
- data/features/step_definitions/reek_steps.rb +12 -0
- data/features/support/env.rb +1 -2
- data/features/support/hooks.rb +15 -0
- data/lib/reek/cli/input.rb +46 -0
- data/lib/reek/cli/options.rb +22 -45
- data/lib/reek/rake/task.rb +9 -1
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +1 -1
- data/spec/samples/configuration_loading/minimal_dirty.rb +4 -0
- data/spec/samples/configuration_loading/reek-test-run-disable_smells.reek +7 -0
- data/spec/samples/configuration_loading/reek-test-run-enable_smells.reek +7 -0
- data/spec/spec_helper.rb +1 -2
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 654a7a3741c1426d2a2e40b05fe4f07515f7fe2e
|
4
|
+
data.tar.gz: c6b97971092b5645f2ae4ee55e5a82859371e360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7272b0e52da60a43de15c0dc72d794554fb01652c054c07be603de16ab52c156fa857e71330b2087528a9fe049bb13366b09e55c60883037e2df199bbdfcf0e5
|
7
|
+
data.tar.gz: 717834c506b575606000461375091233f5d90b5cbd8bc3ccf6bb9b7fc93d4035ad4944d5b4ba570f16a7249cb1b72681d377f44f5e44ae487f4c0627dad97d39
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -54,6 +54,43 @@ spec/samples/demo/demo.rb -- 6 warnings:
|
|
54
54
|
Dirty#awful has unused parameter 'y' (UnusedParameters)
|
55
55
|
```
|
56
56
|
|
57
|
+
## Sources
|
58
|
+
|
59
|
+
There are multiple ways you can have `reek` work on sources, the most common one just being
|
60
|
+
|
61
|
+
```Bash
|
62
|
+
reek lib/
|
63
|
+
```
|
64
|
+
|
65
|
+
If you don't pass any source arguments to `reek` it just takes the current working directory as source.
|
66
|
+
|
67
|
+
So
|
68
|
+
|
69
|
+
```Bash
|
70
|
+
reek
|
71
|
+
```
|
72
|
+
|
73
|
+
is the exact same thing like being explicit:
|
74
|
+
|
75
|
+
```Bash
|
76
|
+
reek .
|
77
|
+
```
|
78
|
+
|
79
|
+
Additionally can you pipe code to reek like this:
|
80
|
+
|
81
|
+
```Bash
|
82
|
+
echo "class C; def m; end; end" | reek
|
83
|
+
```
|
84
|
+
|
85
|
+
This would print out:
|
86
|
+
|
87
|
+
```Bash
|
88
|
+
$stdin -- 3 warnings:
|
89
|
+
[1]:C has no descriptive comment (IrresponsibleModule)
|
90
|
+
[1]:C has the name 'C' (UncommunicativeModuleName)
|
91
|
+
[1]:C#m has the name 'm' (UncommunicativeMethodName)
|
92
|
+
```
|
93
|
+
|
57
94
|
## Code smells
|
58
95
|
|
59
96
|
`reek` currently includes checks for some aspects of [Control Couple](https://github.com/troessner/reek/wiki/Control-Couple), [Data Clump](https://github.com/troessner/reek/wiki/Data-Clump), [Feature Envy](https://github.com/troessner/reek/wiki/Feature-Envy), [Large Class](https://github.com/troessner/reek/wiki/Large-Class), [Long Parameter List](https://github.com/troessner/reek/wiki/Long-Parameter-List), [Simulated Polymorphism](https://github.com/troessner/reek/wiki/Simulated-Polymorphism), [Too Many Statements](https://github.com/troessner/reek/wiki/Too-Many-Statements), [Uncommunicative Name](https://github.com/troessner/reek/wiki/Uncommunicative-Name), [Unused Parameters](https://github.com/troessner/reek/wiki/Unused-Parameters) and more. See the [Code Smells](https://github.com/troessner/reek/wiki/Code-Smells) for up to date details of exactly what `reek` will check in your code.
|
@@ -0,0 +1,62 @@
|
|
1
|
+
Feature: Offer different ways how to load configuration
|
2
|
+
|
3
|
+
There are 3 ways of passing reek a configuration file:
|
4
|
+
- Using the cli "-c" switch
|
5
|
+
- Having a file ending with .reek either in your current working directory or in a parent directory
|
6
|
+
- Having a file ending with .reek in your HOME directory
|
7
|
+
The order in which reek tries to find such a configuration file should exactly be like above:
|
8
|
+
First reek should check if we have given it a configuration file explicitly via CLI.
|
9
|
+
Then it should check the current working directory for a file and if it can't find one,
|
10
|
+
it should traverse up the directories until it hits the root directory.
|
11
|
+
And finally, it should check your HOME directory.
|
12
|
+
|
13
|
+
Scenario: No configuration
|
14
|
+
When I run reek spec/samples/configuration_loading/minimal_dirty.rb
|
15
|
+
Then the exit status indicates smells
|
16
|
+
And it reports:
|
17
|
+
"""
|
18
|
+
spec/samples/configuration_loading/minimal_dirty.rb -- 3 warnings:
|
19
|
+
[1]:C has no descriptive comment (IrresponsibleModule)
|
20
|
+
[1]:C has the name 'C' (UncommunicativeModuleName)
|
21
|
+
[2]:C#m has the name 'm' (UncommunicativeMethodName)
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Configuration via CLI
|
25
|
+
When I run reek -c spec/samples/minimal_smelly_and_masked/config.reek spec/samples/minimal_smelly_and_masked/minimal_dirty.rb
|
26
|
+
Then it reports no errors
|
27
|
+
And it succeeds
|
28
|
+
|
29
|
+
@remove-disable-smell-config-from-current-dir
|
30
|
+
Scenario: Configuration file in working directory
|
31
|
+
Given "spec/samples/configuration_loading/reek-test-run-disable_smells.reek" exists in the working directory
|
32
|
+
When I run reek spec/samples/configuration_loading/minimal_dirty.rb
|
33
|
+
Then it reports no errors
|
34
|
+
And it succeeds
|
35
|
+
|
36
|
+
@remove-disable-smell-config-from-parent-dir
|
37
|
+
Scenario: Configuration file in the parent directory of the working directory
|
38
|
+
Given "spec/samples/configuration_loading/reek-test-run-disable_smells.reek" exists in the parent directory of the working directory
|
39
|
+
When I run reek spec/samples/configuration_loading/minimal_dirty.rb
|
40
|
+
Then it reports no errors
|
41
|
+
And it succeeds
|
42
|
+
|
43
|
+
@remove-disable-smell-config-from-home-dir
|
44
|
+
Scenario: Configuration file in the HOME directory
|
45
|
+
Given "spec/samples/configuration_loading/reek-test-run-disable_smells.reek" exists in the HOME directory
|
46
|
+
When I run reek spec/samples/configuration_loading/minimal_dirty.rb
|
47
|
+
Then it reports no errors
|
48
|
+
And it succeeds
|
49
|
+
|
50
|
+
@remove-enable-smell-config-from-current-dir @remove-disable-smell-config-from-parent-dir
|
51
|
+
Scenario: Two opposing configuration files and we stop after the first one
|
52
|
+
Given "spec/samples/configuration_loading/reek-test-run-enable_smells.reek" exists in the working directory
|
53
|
+
And "spec/samples/configuration_loading/reek-test-run-disable_smells.reek" exists in the parent directory of the working directory
|
54
|
+
When I run reek spec/samples/configuration_loading/minimal_dirty.rb
|
55
|
+
Then the exit status indicates smells
|
56
|
+
And it reports:
|
57
|
+
"""
|
58
|
+
spec/samples/configuration_loading/minimal_dirty.rb -- 3 warnings:
|
59
|
+
[1]:C has no descriptive comment (IrresponsibleModule)
|
60
|
+
[1]:C has the name 'C' (UncommunicativeModuleName)
|
61
|
+
[2]:C#m has the name 'm' (UncommunicativeMethodName)
|
62
|
+
"""
|
@@ -67,3 +67,15 @@ end
|
|
67
67
|
Then /^it reports the current version$/ do
|
68
68
|
expect(@last_stdout).to eq "reek #{Reek::VERSION}\n"
|
69
69
|
end
|
70
|
+
|
71
|
+
Given(/^"(.*?)" exists in the working directory$/) do |path|
|
72
|
+
FileUtils.cp path, Pathname.pwd
|
73
|
+
end
|
74
|
+
|
75
|
+
Given(/^"(.*?)" exists in the parent directory of the working directory$/) do |path|
|
76
|
+
FileUtils.cp path, Pathname.pwd.parent
|
77
|
+
end
|
78
|
+
|
79
|
+
Given(/^"(.*?)" exists in the HOME directory$/) do |path|
|
80
|
+
FileUtils.cp path, Pathname.new(Dir.home)
|
81
|
+
end
|
data/features/support/env.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
After('@remove-disable-smell-config-from-current-dir') do
|
2
|
+
Pathname.pwd.join('reek-test-run-disable_smells.reek').delete
|
3
|
+
end
|
4
|
+
|
5
|
+
After('@remove-disable-smell-config-from-parent-dir') do
|
6
|
+
Pathname.pwd.parent.join('reek-test-run-disable_smells.reek').delete
|
7
|
+
end
|
8
|
+
|
9
|
+
After('@remove-disable-smell-config-from-home-dir') do
|
10
|
+
Pathname.new(Dir.home).join('reek-test-run-disable_smells.reek').delete
|
11
|
+
end
|
12
|
+
|
13
|
+
After('@remove-enable-smell-config-from-current-dir') do
|
14
|
+
Pathname.pwd.join('reek-test-run-enable_smells.reek').delete
|
15
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'reek/source'
|
2
|
+
|
3
|
+
module Reek
|
4
|
+
module CLI
|
5
|
+
#
|
6
|
+
# CLI Input utility
|
7
|
+
#
|
8
|
+
module Input
|
9
|
+
def sources
|
10
|
+
if input_was_piped?
|
11
|
+
source_from_pipe
|
12
|
+
else
|
13
|
+
if no_source_files_given?
|
14
|
+
working_directory_as_source
|
15
|
+
else
|
16
|
+
sources_from_argv
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def input_was_piped?
|
24
|
+
!$stdin.tty?
|
25
|
+
end
|
26
|
+
|
27
|
+
def no_source_files_given?
|
28
|
+
# At this point we have deleted all options from @argv. The only remaining entries
|
29
|
+
# are paths to the source files. If @argv is empty, this means that no files were given.
|
30
|
+
@argv.empty?
|
31
|
+
end
|
32
|
+
|
33
|
+
def working_directory_as_source
|
34
|
+
Source::SourceLocator.new(['.']).all_sources
|
35
|
+
end
|
36
|
+
|
37
|
+
def sources_from_argv
|
38
|
+
Source::SourceLocator.new(@argv).all_sources
|
39
|
+
end
|
40
|
+
|
41
|
+
def source_from_pipe
|
42
|
+
[$stdin.to_reek_source('$stdin')]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/reek/cli/options.rb
CHANGED
@@ -6,7 +6,7 @@ require 'reek/cli/report/strategy'
|
|
6
6
|
require 'reek/cli/reek_command'
|
7
7
|
require 'reek/cli/help_command'
|
8
8
|
require 'reek/cli/version_command'
|
9
|
-
require 'reek/
|
9
|
+
require 'reek/cli/input'
|
10
10
|
|
11
11
|
module Reek
|
12
12
|
module Cli
|
@@ -14,50 +14,38 @@ module Reek
|
|
14
14
|
# Parses the command line
|
15
15
|
#
|
16
16
|
class Options
|
17
|
+
include CLI::Input
|
18
|
+
|
19
|
+
attr_reader :config_file, :smells_to_detect
|
20
|
+
|
17
21
|
def initialize(argv)
|
18
|
-
@argv
|
19
|
-
@parser
|
20
|
-
@colored
|
21
|
-
@report_class
|
22
|
-
@strategy
|
23
|
-
@warning_formatter
|
24
|
-
@command_class
|
25
|
-
@config_file
|
22
|
+
@argv = argv
|
23
|
+
@parser = OptionParser.new
|
24
|
+
@colored = true
|
25
|
+
@report_class = Report::TextReport
|
26
|
+
@strategy = Report::Strategy::Quiet
|
27
|
+
@warning_formatter = Report::WarningFormatterWithLineNumbers
|
28
|
+
@command_class = ReekCommand
|
29
|
+
@config_file = nil
|
26
30
|
@sort_by_issue_count = false
|
27
|
-
@smells_to_detect
|
31
|
+
@smells_to_detect = []
|
28
32
|
set_options
|
29
33
|
end
|
30
34
|
|
31
35
|
def banner
|
32
36
|
progname = @parser.program_name
|
33
|
-
|
34
|
-
|
35
|
-
# are really sub-commands (in the git/svn sense) and so the usage
|
36
|
-
# banner should show three different command-lines. The other
|
37
|
-
# options are all flags for the Reek sub-command.
|
38
|
-
#
|
39
|
-
# reek -h|--help Display a help message
|
40
|
-
#
|
41
|
-
# reek -v|--version Output the tool's version number
|
42
|
-
#
|
43
|
-
# reek [options] files List the smells in the given files
|
44
|
-
# -c|--config file Specify file(s) with config options
|
45
|
-
# -n|--line-number Prefix smelly lines with line numbers
|
46
|
-
# -q|-[no-]quiet Only list files that have smells
|
47
|
-
# files Names of files or dirs to be checked
|
48
|
-
#
|
49
|
-
<<EOB
|
50
|
-
Usage: #{progname} [options] [files]
|
37
|
+
<<-EOB.gsub(/^[ ]+/, '')
|
38
|
+
Usage: #{progname} [options] [files]
|
51
39
|
|
52
|
-
Examples:
|
40
|
+
Examples:
|
53
41
|
|
54
|
-
#{progname} lib/*.rb
|
55
|
-
#{progname} -q lib
|
56
|
-
cat my_class.rb | #{progname}
|
42
|
+
#{progname} lib/*.rb
|
43
|
+
#{progname} -q lib
|
44
|
+
cat my_class.rb | #{progname}
|
57
45
|
|
58
|
-
See http://wiki.github.com/troessner/reek for detailed help.
|
46
|
+
See http://wiki.github.com/troessner/reek for detailed help.
|
59
47
|
|
60
|
-
EOB
|
48
|
+
EOB
|
61
49
|
end
|
62
50
|
|
63
51
|
def set_options
|
@@ -117,9 +105,6 @@ EOB
|
|
117
105
|
@command_class.new(self)
|
118
106
|
end
|
119
107
|
|
120
|
-
attr_reader :config_file
|
121
|
-
attr_reader :smells_to_detect
|
122
|
-
|
123
108
|
def reporter
|
124
109
|
@reporter ||= @report_class.new(warning_formatter: @warning_formatter,
|
125
110
|
report_formatter: Report::Formatter,
|
@@ -127,14 +112,6 @@ EOB
|
|
127
112
|
strategy: @strategy)
|
128
113
|
end
|
129
114
|
|
130
|
-
def sources
|
131
|
-
if @argv.empty?
|
132
|
-
return [$stdin.to_reek_source('$stdin')]
|
133
|
-
else
|
134
|
-
return Source::SourceLocator.new(@argv).all_sources
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
115
|
def program_name
|
139
116
|
@parser.program_name
|
140
117
|
end
|
data/lib/reek/rake/task.rb
CHANGED
@@ -115,10 +115,18 @@ module Reek
|
|
115
115
|
ruby_options +
|
116
116
|
[%(reek)] +
|
117
117
|
[sort_option] +
|
118
|
-
|
118
|
+
config_option +
|
119
119
|
source_file_list.map { |fn| %("#{fn}") }
|
120
120
|
end
|
121
121
|
|
122
|
+
def config_option
|
123
|
+
if config_file
|
124
|
+
['-c', config_file]
|
125
|
+
else
|
126
|
+
[]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
122
130
|
def config_file
|
123
131
|
ENV['REEK_CFG'] || @config_file
|
124
132
|
end
|
data/lib/reek/version.rb
CHANGED
data/reek.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.summary = 'Code smell detector for Ruby'
|
32
32
|
|
33
33
|
s.add_runtime_dependency('parser', ['~> 2.2.0.pre.7'])
|
34
|
-
s.add_runtime_dependency('unparser', ['
|
34
|
+
s.add_runtime_dependency('unparser', ['= 0.1.16'])
|
35
35
|
s.add_runtime_dependency('rainbow', ['>= 1.99', '< 3.0'])
|
36
36
|
|
37
37
|
s.add_development_dependency('bundler', ['~> 1.1'])
|
data/spec/spec_helper.rb
CHANGED
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: 1.6.
|
4
|
+
version: 1.6.2
|
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:
|
13
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parser
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
name: unparser
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: 0.1.16
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 0.1.16
|
43
43
|
- !ruby/object:Gem::Dependency
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- features/command_line_interface/stdin.feature
|
191
191
|
- features/configuration_files/masking_smells.feature
|
192
192
|
- features/configuration_files/overrides_defaults.feature
|
193
|
+
- features/configuration_loading.feature
|
193
194
|
- features/rake_task/rake_task.feature
|
194
195
|
- features/reports/reports.feature
|
195
196
|
- features/reports/yaml.feature
|
@@ -197,10 +198,12 @@ files:
|
|
197
198
|
- features/samples.feature
|
198
199
|
- features/step_definitions/reek_steps.rb
|
199
200
|
- features/support/env.rb
|
201
|
+
- features/support/hooks.rb
|
200
202
|
- lib/reek.rb
|
201
203
|
- lib/reek/cli/application.rb
|
202
204
|
- lib/reek/cli/command.rb
|
203
205
|
- lib/reek/cli/help_command.rb
|
206
|
+
- lib/reek/cli/input.rb
|
204
207
|
- lib/reek/cli/options.rb
|
205
208
|
- lib/reek/cli/reek_command.rb
|
206
209
|
- lib/reek/cli/report/formatter.rb
|
@@ -338,6 +341,9 @@ files:
|
|
338
341
|
- spec/samples/clean_due_to_masking/masked.reek
|
339
342
|
- spec/samples/config/allow_duplication.reek
|
340
343
|
- spec/samples/config/deeper_nested_iterators.reek
|
344
|
+
- spec/samples/configuration_loading/minimal_dirty.rb
|
345
|
+
- spec/samples/configuration_loading/reek-test-run-disable_smells.reek
|
346
|
+
- spec/samples/configuration_loading/reek-test-run-enable_smells.reek
|
341
347
|
- spec/samples/corrupt_config_file/corrupt.reek
|
342
348
|
- spec/samples/corrupt_config_file/dirty.rb
|
343
349
|
- spec/samples/demo/demo.rb
|
@@ -413,7 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
413
419
|
version: '0'
|
414
420
|
requirements: []
|
415
421
|
rubyforge_project: reek
|
416
|
-
rubygems_version: 2.
|
422
|
+
rubygems_version: 2.4.4
|
417
423
|
signing_key:
|
418
424
|
specification_version: 4
|
419
425
|
summary: Code smell detector for Ruby
|