reek 1.3.6 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/README.md +11 -1
- data/config/defaults.reek +1 -0
- data/features/command_line_interface/options.feature +1 -0
- data/features/rake_task/rake_task.feature +3 -0
- data/features/ruby_api/api.feature +1 -3
- data/features/samples.feature +27 -20
- data/features/support/env.rb +2 -2
- data/lib/reek/cli/application.rb +0 -4
- data/lib/reek/cli/command_line.rb +10 -12
- data/lib/reek/cli/reek_command.rb +1 -1
- data/lib/reek/cli/report.rb +36 -8
- data/lib/reek/config_file_exception.rb +3 -0
- data/lib/reek/core/code_context.rb +18 -8
- data/lib/reek/core/code_parser.rb +65 -61
- data/lib/reek/core/method_context.rb +4 -0
- data/lib/reek/core/module_context.rb +2 -2
- data/lib/reek/core/smell_repository.rb +3 -0
- data/lib/reek/core/sniffer.rb +0 -1
- data/lib/reek/core/stop_context.rb +1 -1
- data/lib/reek/smells/attribute.rb +1 -1
- data/lib/reek/smells/control_parameter.rb +79 -45
- data/lib/reek/smells/data_clump.rb +1 -1
- data/lib/reek/smells/duplicate_method_call.rb +1 -1
- data/lib/reek/smells/long_parameter_list.rb +1 -1
- data/lib/reek/smells/long_yield_list.rb +1 -1
- data/lib/reek/smells/nested_iterators.rb +1 -1
- data/lib/reek/smells/nil_check.rb +10 -5
- data/lib/reek/smells/repeated_conditional.rb +1 -1
- data/lib/reek/smells/smell_detector.rb +2 -3
- 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 +4 -4
- data/lib/reek/smells/uncommunicative_module_name.rb +4 -4
- data/lib/reek/smells/uncommunicative_parameter_name.rb +9 -9
- data/lib/reek/smells/uncommunicative_variable_name.rb +1 -1
- data/lib/reek/smells/unused_parameters.rb +2 -6
- data/lib/reek/smells/utility_function.rb +1 -1
- data/lib/reek/source/code_comment.rb +1 -1
- data/lib/reek/source/config_file.rb +9 -8
- data/lib/reek/source/sexp_extensions.rb +2 -2
- data/lib/reek/source/sexp_node.rb +8 -5
- data/lib/reek/source/source_repository.rb +5 -0
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +3 -2
- data/spec/reek/cli/report_spec.rb +38 -8
- data/spec/reek/core/code_context_spec.rb +35 -3
- data/spec/reek/core/module_context_spec.rb +1 -1
- data/spec/reek/smells/repeated_conditional_spec.rb +1 -1
- data/spec/reek/smells/smell_detector_shared.rb +1 -2
- data/spec/reek/smells/too_many_statements_spec.rb +39 -25
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +44 -30
- data/spec/reek/smells/unused_parameters_spec.rb +15 -11
- data/spec/reek/source/sexp_extensions_spec.rb +2 -2
- data/spec/reek/source/sexp_node_spec.rb +0 -1
- data/spec/samples/ruby20_syntax.rb +1 -5
- metadata +172 -162
- data/lib/reek/cli/yaml_command.rb +0 -32
- data/lib/reek/core/hash_extensions.rb +0 -29
- data/spec/reek/cli/yaml_command_spec.rb +0 -47
- data/spec/reek/core/config_spec.rb +0 -38
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'reek/examiner'
|
2
|
-
|
3
|
-
module Reek
|
4
|
-
module Cli
|
5
|
-
|
6
|
-
#
|
7
|
-
# A command to collect smells from a set of sources and write them out in
|
8
|
-
# YAML format.
|
9
|
-
#
|
10
|
-
class YamlCommand
|
11
|
-
def self.create(sources, config_files)
|
12
|
-
examiners = sources.map {|src| Examiner.new(src, config_files) }
|
13
|
-
new(examiners)
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(examiners)
|
17
|
-
@examiners = examiners
|
18
|
-
end
|
19
|
-
|
20
|
-
def execute(view)
|
21
|
-
smells = []
|
22
|
-
@examiners.each {|examiner| smells += examiner.smells}
|
23
|
-
if smells.empty?
|
24
|
-
view.report_success
|
25
|
-
else
|
26
|
-
view.output(smells.to_yaml)
|
27
|
-
view.report_smells
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Extensions to +Hash+ needed by Reek.
|
3
|
-
#
|
4
|
-
class Hash
|
5
|
-
def push_keys(hash)
|
6
|
-
keys.each {|key| hash[key].adopt!(self[key]) }
|
7
|
-
end
|
8
|
-
|
9
|
-
def adopt!(other)
|
10
|
-
other.keys.each do |key|
|
11
|
-
ov = other[key]
|
12
|
-
if Array === ov and has_key?(key)
|
13
|
-
self[key] += ov
|
14
|
-
else
|
15
|
-
self[key] = ov
|
16
|
-
end
|
17
|
-
end
|
18
|
-
self
|
19
|
-
end
|
20
|
-
|
21
|
-
def adopt(other)
|
22
|
-
self.deep_copy.adopt!(other)
|
23
|
-
end
|
24
|
-
|
25
|
-
def deep_copy
|
26
|
-
YAML::load(YAML::dump(self))
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'reek/cli/yaml_command'
|
3
|
-
|
4
|
-
include Reek
|
5
|
-
include Reek::Cli
|
6
|
-
|
7
|
-
describe YamlCommand do
|
8
|
-
before :each do
|
9
|
-
@view = double('view').as_null_object
|
10
|
-
@examiner = double('examiner')
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'with no smells' do
|
14
|
-
before :each do
|
15
|
-
@examiner.should_receive(:smells).and_return([])
|
16
|
-
@cmd = YamlCommand.new([@examiner])
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'displays nothing on the view' do
|
20
|
-
@view.should_not_receive(:output)
|
21
|
-
@cmd.execute(@view)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'tells the view it succeeded' do
|
25
|
-
@view.should_receive(:report_success)
|
26
|
-
@cmd.execute(@view)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'with smells' do
|
31
|
-
before :each do
|
32
|
-
@smell = SmellWarning.new('UncommunicativeName', "self", 27, "self")
|
33
|
-
@examiner.should_receive(:smells).and_return([@smell])
|
34
|
-
@cmd = YamlCommand.new([@examiner])
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'displays the correct text on the view' do
|
38
|
-
@view.should_receive(:output).with(/UncommunicativeName/)
|
39
|
-
@cmd.execute(@view)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'tells the view it found smells' do
|
43
|
-
@view.should_receive(:report_smells)
|
44
|
-
@cmd.execute(@view)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'reek/core/sniffer'
|
3
|
-
|
4
|
-
describe Hash do
|
5
|
-
before :each do
|
6
|
-
@first = {
|
7
|
-
'one' => {'two' => 3, 'three' => 4},
|
8
|
-
'two' => {'four' => true}
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should deep merge Hashes' do
|
13
|
-
other = Hash.new {|hash,key| hash[key] = {} }
|
14
|
-
other['one']['gunk'] = 45
|
15
|
-
other['two']['four'] = false
|
16
|
-
other.push_keys(@first)
|
17
|
-
@first['two']['four'].should == false
|
18
|
-
@first['one'].keys.length.should == 3
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should deep copy Hashes' do
|
22
|
-
second = @first.deep_copy
|
23
|
-
second['two'].object_id.should_not be_eql(@first['two'].object_id)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should merge array values' do
|
27
|
-
@first['three'] = [1,2,3]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe Hash, 'merging arrays' do
|
32
|
-
it 'should merge array values' do
|
33
|
-
first = {'key' => {'one' => [1,2,3]}}
|
34
|
-
second = {'key' => {'one' => [4,5]}}
|
35
|
-
second.push_keys(first)
|
36
|
-
first['key']['one'].should == [1,2,3,4,5]
|
37
|
-
end
|
38
|
-
end
|