reek 4.0.1 → 4.0.2
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/CHANGELOG.md +6 -0
- data/Gemfile +3 -3
- data/README.md +1 -1
- data/docs/Attribute.md +1 -1
- data/docs/Boolean-Parameter.md +8 -6
- data/docs/Class-Variable.md +1 -1
- data/docs/Command-Line-Options.md +26 -1
- data/docs/Control-Couple.md +13 -9
- data/docs/Control-Parameter.md +8 -5
- data/docs/Data-Clump.md +9 -7
- data/docs/Duplicate-Method-Call.md +1 -1
- data/docs/Irresponsible-Module.md +4 -3
- data/docs/Large-Class.md +7 -12
- data/docs/Long-Parameter-List.md +7 -6
- data/docs/Long-Yield-List.md +7 -6
- data/docs/Nested-Iterators.md +7 -7
- data/docs/Nil-Check.md +8 -4
- data/docs/Prima-Donna-Method.md +19 -9
- data/docs/Reek-Driven-Development.md +3 -1
- data/docs/Repeated-Conditional.md +5 -2
- data/docs/Too-Many-Instance-Variables.md +7 -7
- data/docs/Too-Many-Methods.md +10 -9
- data/docs/Too-Many-Statements.md +8 -4
- data/docs/Uncommunicative-Method-Name.md +8 -7
- data/docs/Uncommunicative-Module-Name.md +8 -8
- data/docs/Uncommunicative-Name.md +5 -3
- data/docs/Uncommunicative-Parameter-Name.md +9 -9
- data/docs/Uncommunicative-Variable-Name.md +8 -7
- data/docs/Unused-Parameters.md +5 -4
- data/docs/Unused-Private-Method.md +3 -3
- data/docs/Utility-Function.md +3 -3
- data/lib/reek/ast/object_refs.rb +4 -4
- data/lib/reek/cli/application.rb +40 -4
- data/lib/reek/cli/command/base_command.rb +3 -2
- data/lib/reek/cli/command/report_command.rb +35 -5
- data/lib/reek/cli/command/todo_list_command.rb +4 -4
- data/lib/reek/configuration/app_configuration.rb +15 -15
- data/lib/reek/configuration/default_directive.rb +2 -1
- data/lib/reek/context/code_context.rb +1 -1
- data/lib/reek/context/module_context.rb +5 -6
- data/lib/reek/spec.rb +6 -4
- data/lib/reek/spec/should_reek_of.rb +11 -3
- data/lib/reek/version.rb +1 -1
- data/spec/factories/factories.rb +0 -11
- data/spec/reek/cli/application_spec.rb +83 -9
- data/spec/reek/cli/command/report_command_spec.rb +17 -14
- data/spec/reek/cli/command/todo_list_command_spec.rb +12 -10
- data/spec/reek/smells/duplicate_method_call_spec.rb +8 -14
- data/spec/reek/smells/nested_iterators_spec.rb +12 -16
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +2 -4
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +2 -4
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +2 -4
- data/spec/reek/smells/unused_private_method_spec.rb +47 -48
- data/spec/reek/smells/utility_function_spec.rb +5 -10
- data/spec/reek/spec/should_reek_of_spec.rb +27 -0
- metadata +2 -6
- data/lib/reek/cli/input.rb +0 -49
- data/lib/reek/cli/option_interpreter.rb +0 -58
- data/spec/reek/cli/input_spec.rb +0 -71
- data/spec/reek/cli/option_interpreter_spec.rb +0 -20
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: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Rutherford
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-04-
|
14
|
+
date: 2016-04-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: codeclimate-engine-rb
|
@@ -190,8 +190,6 @@ files:
|
|
190
190
|
- lib/reek/cli/command/base_command.rb
|
191
191
|
- lib/reek/cli/command/report_command.rb
|
192
192
|
- lib/reek/cli/command/todo_list_command.rb
|
193
|
-
- lib/reek/cli/input.rb
|
194
|
-
- lib/reek/cli/option_interpreter.rb
|
195
193
|
- lib/reek/cli/options.rb
|
196
194
|
- lib/reek/cli/silencer.rb
|
197
195
|
- lib/reek/cli/warning_collector.rb
|
@@ -280,8 +278,6 @@ files:
|
|
280
278
|
- spec/reek/cli/application_spec.rb
|
281
279
|
- spec/reek/cli/command/report_command_spec.rb
|
282
280
|
- spec/reek/cli/command/todo_list_command_spec.rb
|
283
|
-
- spec/reek/cli/input_spec.rb
|
284
|
-
- spec/reek/cli/option_interpreter_spec.rb
|
285
281
|
- spec/reek/cli/options_spec.rb
|
286
282
|
- spec/reek/cli/warning_collector_spec.rb
|
287
283
|
- spec/reek/code_comment_spec.rb
|
data/lib/reek/cli/input.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require_relative '../source/source_locator'
|
3
|
-
|
4
|
-
module Reek
|
5
|
-
module CLI
|
6
|
-
#
|
7
|
-
# CLI Input utility
|
8
|
-
#
|
9
|
-
module Input
|
10
|
-
def sources
|
11
|
-
if no_source_files_given?
|
12
|
-
if input_was_piped?
|
13
|
-
source_from_pipe
|
14
|
-
else
|
15
|
-
working_directory_as_source
|
16
|
-
end
|
17
|
-
else
|
18
|
-
sources_from_argv
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
# :reek:UtilityFunction
|
25
|
-
def input_was_piped?
|
26
|
-
!$stdin.tty?
|
27
|
-
end
|
28
|
-
|
29
|
-
def no_source_files_given?
|
30
|
-
# At this point we have deleted all options from argv. The only remaining entries
|
31
|
-
# are paths to the source files. If argv is empty, this means that no files were given.
|
32
|
-
argv.empty?
|
33
|
-
end
|
34
|
-
|
35
|
-
# :reek:UtilityFunction
|
36
|
-
def working_directory_as_source
|
37
|
-
Source::SourceLocator.new(['.'], configuration: configuration).sources
|
38
|
-
end
|
39
|
-
|
40
|
-
def sources_from_argv
|
41
|
-
Source::SourceLocator.new(argv).sources
|
42
|
-
end
|
43
|
-
|
44
|
-
def source_from_pipe
|
45
|
-
[$stdin]
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'forwardable'
|
3
|
-
require_relative 'input'
|
4
|
-
require_relative '../report'
|
5
|
-
|
6
|
-
module Reek
|
7
|
-
module CLI
|
8
|
-
#
|
9
|
-
# Interprets the options set from the command line
|
10
|
-
#
|
11
|
-
class OptionInterpreter
|
12
|
-
extend Forwardable
|
13
|
-
def_delegators :options, :smells_to_detect, :success_exit_code, :failure_exit_code
|
14
|
-
|
15
|
-
def initialize(options)
|
16
|
-
@options = options
|
17
|
-
@argv = options.argv
|
18
|
-
end
|
19
|
-
|
20
|
-
def reporter
|
21
|
-
@reporter ||=
|
22
|
-
report_class.new(
|
23
|
-
warning_formatter: warning_formatter,
|
24
|
-
report_formatter: Report::Formatter,
|
25
|
-
sort_by_issue_count: sort_by_issue_count,
|
26
|
-
heading_formatter: heading_formatter)
|
27
|
-
end
|
28
|
-
|
29
|
-
def report_class
|
30
|
-
Report.report_class(options.report_format)
|
31
|
-
end
|
32
|
-
|
33
|
-
def warning_formatter
|
34
|
-
warning_formatter_class.new(location_formatter: location_formatter)
|
35
|
-
end
|
36
|
-
|
37
|
-
def warning_formatter_class
|
38
|
-
Report.warning_formatter_class(options.show_links ? :wiki_links : :simple)
|
39
|
-
end
|
40
|
-
|
41
|
-
def location_formatter
|
42
|
-
Report.location_formatter(options.location_format)
|
43
|
-
end
|
44
|
-
|
45
|
-
def heading_formatter
|
46
|
-
Report.heading_formatter(options.show_empty ? :verbose : :quiet)
|
47
|
-
end
|
48
|
-
|
49
|
-
def sort_by_issue_count
|
50
|
-
options.sorting == :smelliness
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
attr_reader :argv, :options
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/spec/reek/cli/input_spec.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/cli/input'
|
3
|
-
|
4
|
-
RSpec.describe Reek::CLI::Input do
|
5
|
-
# dummy class which includes module under test
|
6
|
-
class DummyClass
|
7
|
-
include Reek::CLI::Input
|
8
|
-
|
9
|
-
def argv; end
|
10
|
-
|
11
|
-
def configuration; end
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:path_excluded_in_configuration) do
|
15
|
-
SAMPLES_PATH.join('source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb')
|
16
|
-
end
|
17
|
-
|
18
|
-
let(:configuration) { test_configuration_for(SAMPLES_PATH.join('configuration/with_excluded_paths.reek')) }
|
19
|
-
|
20
|
-
subject { DummyClass.new }
|
21
|
-
|
22
|
-
before do
|
23
|
-
allow(subject).to receive(:configuration).and_return(configuration)
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#sources' do
|
27
|
-
context 'when no source files given' do
|
28
|
-
before do
|
29
|
-
allow(subject).to receive(:argv).and_return([])
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'and input was piped' do
|
33
|
-
before do
|
34
|
-
allow_any_instance_of(IO).to receive(:tty?).and_return(false)
|
35
|
-
expect(subject).to receive(:source_from_pipe).and_call_original
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should use source form pipe' do
|
39
|
-
expect(subject.sources).to_not be_empty
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'and input was not piped' do
|
44
|
-
before do
|
45
|
-
allow_any_instance_of(IO).to receive(:tty?).and_return(true)
|
46
|
-
expect(subject).to receive(:working_directory_as_source).
|
47
|
-
and_call_original
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should use working directory as source' do
|
51
|
-
expect(subject.sources).to_not be_empty
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should use configuration for excluded paths' do
|
55
|
-
expect(subject.sources).to_not include(path_excluded_in_configuration)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when source files given' do
|
61
|
-
before do
|
62
|
-
allow(subject).to receive(:argv).and_return(['.'])
|
63
|
-
expect(subject).to receive(:sources_from_argv).and_call_original
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should use sources from argv' do
|
67
|
-
expect(subject.sources).to_not be_empty
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative '../../spec_helper'
|
2
|
-
|
3
|
-
require_lib 'reek/cli/options'
|
4
|
-
require_lib 'reek/cli/option_interpreter'
|
5
|
-
require_lib 'reek/report/report'
|
6
|
-
|
7
|
-
RSpec.describe Reek::CLI::OptionInterpreter do
|
8
|
-
describe '#reporter' do
|
9
|
-
context 'with a valid set of options' do
|
10
|
-
let(:options) do
|
11
|
-
Reek::CLI::Options.new.parse
|
12
|
-
end
|
13
|
-
subject { described_class.new(options) }
|
14
|
-
|
15
|
-
it 'returns an object of the correct subclass of Report::Base' do
|
16
|
-
expect(subject.reporter).to be_instance_of Reek::Report::TextReport
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|