reek 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +6 -0
  3. data/README.md +15 -9
  4. data/bin/reek +1 -1
  5. data/config/defaults.reek +71 -86
  6. data/features/command_line_interface/options.feature +0 -15
  7. data/features/reports/reports.feature +23 -0
  8. data/features/samples.feature +3 -12
  9. data/lib/reek.rb +3 -3
  10. data/lib/reek/cli/application.rb +1 -1
  11. data/lib/reek/cli/command_line.rb +10 -8
  12. data/lib/reek/cli/reek_command.rb +6 -7
  13. data/lib/reek/cli/report.rb +34 -38
  14. data/lib/reek/cli/version_command.rb +1 -1
  15. data/lib/reek/cli/yaml_command.rb +1 -1
  16. data/lib/reek/core/code_parser.rb +4 -4
  17. data/lib/reek/core/hash_extensions.rb +2 -2
  18. data/lib/reek/core/method_context.rb +2 -2
  19. data/lib/reek/core/module_context.rb +4 -4
  20. data/lib/reek/core/singleton_method_context.rb +1 -1
  21. data/lib/reek/core/smell_repository.rb +7 -6
  22. data/lib/reek/core/sniffer.rb +4 -4
  23. data/lib/reek/examiner.rb +10 -3
  24. data/lib/reek/smell_warning.rb +0 -2
  25. data/lib/reek/smells.rb +22 -21
  26. data/lib/reek/smells/attribute.rb +4 -8
  27. data/lib/reek/smells/boolean_parameter.rb +2 -2
  28. data/lib/reek/smells/class_variable.rb +3 -2
  29. data/lib/reek/smells/{control_couple.rb → control_parameter.rb} +5 -5
  30. data/lib/reek/smells/data_clump.rb +13 -29
  31. data/lib/reek/smells/{duplication.rb → duplicate_method_call.rb} +9 -11
  32. data/lib/reek/smells/feature_envy.rb +2 -2
  33. data/lib/reek/smells/irresponsible_module.rb +3 -2
  34. data/lib/reek/smells/long_parameter_list.rb +6 -10
  35. data/lib/reek/smells/long_yield_list.rb +4 -8
  36. data/lib/reek/smells/nested_iterators.rb +31 -25
  37. data/lib/reek/smells/nil_check.rb +11 -12
  38. data/lib/reek/smells/{simulated_polymorphism.rb → repeated_conditional.rb} +6 -10
  39. data/lib/reek/smells/smell_detector.rb +3 -6
  40. data/lib/reek/smells/too_many_instance_variables.rb +60 -0
  41. data/lib/reek/smells/too_many_methods.rb +62 -0
  42. data/lib/reek/smells/{long_method.rb → too_many_statements.rb} +7 -12
  43. data/lib/reek/smells/uncommunicative_method_name.rb +3 -7
  44. data/lib/reek/smells/uncommunicative_module_name.rb +3 -7
  45. data/lib/reek/smells/uncommunicative_parameter_name.rb +4 -8
  46. data/lib/reek/smells/uncommunicative_variable_name.rb +5 -9
  47. data/lib/reek/smells/unused_parameters.rb +62 -13
  48. data/lib/reek/smells/utility_function.rb +3 -7
  49. data/lib/reek/source.rb +8 -8
  50. data/lib/reek/source/core_extras.rb +1 -1
  51. data/lib/reek/source/source_code.rb +2 -2
  52. data/lib/reek/source/source_file.rb +2 -2
  53. data/lib/reek/source/source_locator.rb +1 -1
  54. data/lib/reek/source/source_repository.rb +4 -2
  55. data/lib/reek/spec.rb +9 -3
  56. data/lib/reek/spec/should_reek.rb +2 -2
  57. data/lib/reek/spec/should_reek_of.rb +1 -1
  58. data/lib/reek/spec/should_reek_only_of.rb +2 -2
  59. data/lib/reek/version.rb +1 -1
  60. data/reek.gemspec +3 -1
  61. data/spec/gem/updates_spec.rb +1 -1
  62. data/spec/gem/yard_spec.rb +1 -1
  63. data/spec/matchers/smell_of_matcher.rb +53 -19
  64. data/spec/reek/cli/help_command_spec.rb +2 -2
  65. data/spec/reek/cli/reek_command_spec.rb +6 -6
  66. data/spec/reek/cli/report_spec.rb +6 -6
  67. data/spec/reek/cli/version_command_spec.rb +2 -2
  68. data/spec/reek/cli/yaml_command_spec.rb +2 -2
  69. data/spec/reek/core/code_context_spec.rb +4 -4
  70. data/spec/reek/core/code_parser_spec.rb +2 -2
  71. data/spec/reek/core/config_spec.rb +4 -4
  72. data/spec/reek/core/method_context_spec.rb +3 -3
  73. data/spec/reek/core/module_context_spec.rb +3 -3
  74. data/spec/reek/core/object_refs_spec.rb +3 -3
  75. data/spec/reek/core/singleton_method_context_spec.rb +4 -4
  76. data/spec/reek/core/smell_configuration_spec.rb +2 -2
  77. data/spec/reek/core/stop_context_spec.rb +2 -2
  78. data/spec/reek/core/warning_collector_spec.rb +3 -3
  79. data/spec/reek/examiner_spec.rb +13 -4
  80. data/spec/reek/smell_warning_spec.rb +2 -2
  81. data/spec/reek/smells/attribute_spec.rb +4 -4
  82. data/spec/reek/smells/boolean_parameter_spec.rb +3 -3
  83. data/spec/reek/smells/class_variable_spec.rb +4 -4
  84. data/spec/reek/smells/{control_couple_spec.rb → control_parameter_spec.rb} +10 -10
  85. data/spec/reek/smells/data_clump_spec.rb +3 -3
  86. data/spec/reek/smells/{duplication_spec.rb → duplicate_method_call_spec.rb} +42 -26
  87. data/spec/reek/smells/feature_envy_spec.rb +3 -3
  88. data/spec/reek/smells/irresponsible_module_spec.rb +3 -3
  89. data/spec/reek/smells/long_parameter_list_spec.rb +3 -3
  90. data/spec/reek/smells/long_yield_list_spec.rb +3 -3
  91. data/spec/reek/smells/nested_iterators_spec.rb +42 -4
  92. data/spec/reek/smells/nil_check_spec.rb +23 -11
  93. data/spec/reek/smells/{simulated_polymorphism_spec.rb → repeated_conditional_spec.rb} +6 -6
  94. data/spec/reek/smells/smell_detector_shared.rb +2 -2
  95. data/spec/reek/smells/too_many_instance_variables_spec.rb +62 -0
  96. data/spec/reek/smells/{large_class_spec.rb → too_many_methods_spec.rb} +11 -56
  97. data/spec/reek/smells/{long_method_spec.rb → too_many_statements_spec.rb} +17 -17
  98. data/spec/reek/smells/uncommunicative_method_name_spec.rb +5 -5
  99. data/spec/reek/smells/uncommunicative_module_name_spec.rb +5 -5
  100. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +4 -4
  101. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +5 -5
  102. data/spec/reek/smells/unused_parameters_spec.rb +19 -4
  103. data/spec/reek/smells/utility_function_spec.rb +3 -3
  104. data/spec/reek/source/code_comment_spec.rb +2 -2
  105. data/spec/reek/source/object_source_spec.rb +1 -1
  106. data/spec/reek/source/reference_collector_spec.rb +2 -2
  107. data/spec/reek/source/sexp_formatter_spec.rb +2 -2
  108. data/spec/reek/source/source_code_spec.rb +2 -2
  109. data/spec/reek/source/tree_dresser_spec.rb +2 -2
  110. data/spec/reek/spec/should_reek_of_spec.rb +2 -2
  111. data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
  112. data/spec/reek/spec/should_reek_spec.rb +2 -2
  113. data/spec/samples/all_but_one_masked/masked.reek +1 -1
  114. data/spec/samples/clean_due_to_masking/masked.reek +1 -1
  115. data/spec/samples/config/allow_duplication.reek +2 -2
  116. data/spec/samples/inline_config/dirty.rb +2 -2
  117. data/spec/samples/mask_some/some.reek +1 -1
  118. data/spec/samples/masked_by_dotfile/dirty.rb +8 -0
  119. data/spec/samples/not_quite_masked/smelly.rb +3 -0
  120. data/spec/samples/overrides/masked/lower.reek +1 -1
  121. data/spec/samples/overrides/upper.reek +1 -1
  122. data/spec/spec_helper.rb +4 -9
  123. data/tasks/test.rake +0 -2
  124. metadata +253 -263
  125. data/lib/reek/smells/large_class.rb +0 -87
  126. data/lib/xp.reek +0 -66
  127. data/spec/gem/manifest_spec.rb +0 -22
  128. data/spec/spec.opts +0 -1
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a338252f57ae1f1a0a900faf8d0e90bde20545b
4
+ data.tar.gz: b3a5757e5b1bd95b40981258c2b32ef356488004
5
+ SHA512:
6
+ metadata.gz: 79b07042b5798fb49fbeeaf3de39785345ddc6b7d9ce219a588f213136063be2e242f687ed70e1ac7cde9a378186f52899ad38b69ce6d704493cf22d183e524a
7
+ data.tar.gz: e79e4e27c15f357b7cfbd6001e9ec0ceaec237c3ccfc896da902aea1825f561365a75c01ed194948460a222aadebc0de928f8a9b3e07e9d28bdd5565265da604
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.3.2
2
+
3
+ * (mvz) Allow duplicate calls to variable-like methods
4
+ * (mvz) Improve NestedIterators smell detector
5
+ * (mvz) Make combination of -n and -q options work
6
+
1
7
  == 1.3.1
2
8
 
3
9
  * (EmilRehnberg) Added smell for nil checks
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Reek -- code smell detection for Ruby
2
2
 
3
+ ##Overview
4
+
3
5
  [![Build Status](https://secure.travis-ci.org/troessner/reek.png?branch=master)](http://travis-ci.org/troessner/reek?branch=master)
6
+ [![Gem Version](https://badge.fury.io/rb/reek.png)](http://badge.fury.io/rb/reek)
7
+
4
8
 
5
9
  Reek is a tool that examines Ruby classes, modules and methods and
6
10
  reports any code smells it finds. Install it like this:
@@ -15,8 +19,8 @@ and run it like this:
15
19
  $ reek [options] [dir_or_source_file]*
16
20
  ```
17
21
 
18
- For a full list of command-line options see the Reek
19
- wiki[http://wiki.github.com/troessner/reek/command-line-options]
22
+ For a full list of command-line options see the
23
+ [Reek wiki](https://github.com/troessner/reek/wiki/command-line-options)
20
24
  or run
21
25
 
22
26
  ```bash
@@ -56,7 +60,7 @@ spec/samples/demo/demo.rb -- 6 warnings:
56
60
  Reek currently includes checks for some aspects of Control Couple,
57
61
  Data Clump, Feature Envy, Large Class, Long Method, Long Parameter List,
58
62
  Simulated Polymorphism, Uncommunicative Name and more.
59
- See the [Reek wiki](http://wiki.github.com/troessner/reek/code-smells)
63
+ See the [Reek wiki](https://github.com/troessner/reek/wiki/code-smells)
60
64
  for up to date details of exactly what Reek will check in your code.
61
65
 
62
66
  ### Integration
@@ -72,7 +76,6 @@ require 'rubygems'
72
76
  require 'spec'
73
77
  require 'reek'
74
78
  require 'reek/spec'
75
- require 'reek/spec'
76
79
 
77
80
  include Reek::Spec
78
81
 
@@ -97,7 +100,11 @@ spec spec/your/file -l 23 # Runs test in line 23
97
100
  spec spec/your/file -u # Runs all tests stopping at the breakpoints you have set before with `debugger`
98
101
  ```
99
102
 
100
- ### Tool Integration
103
+ ## Miscellaneous
104
+
105
+ ### Tools
106
+
107
+ There's a vim plugin for `reek`: [https://github.com/rainerborene/vim-reek](https://github.com/rainerborene/vim-reek)
101
108
 
102
109
  ### Dependencies
103
110
 
@@ -107,12 +114,11 @@ Reek makes use of the following other gems:
107
114
  * sexp_processor
108
115
  * ruby2ruby
109
116
 
110
- Learn More
111
- ----------
117
+ ### Learn More
112
118
 
113
119
  Find out more about Reek from any of the following sources:
114
120
 
115
- * Browse the Reek documentation at [http://wiki.github.com/troessner/reek](http://wiki.github.com/troessner/reek)
116
- * Browse the code or install the latest development version from [http://github.com/troessner/reek/tree](http://github.com/troessner/reek/tree)
121
+ * Browse the Reek documentation at [https://github.com/troessner/reek/wiki](https://github.com/troessner/reek/wiki)
122
+ * Browse the code or install the latest development version from [https://github.com/troessner/reek/tree](https://github.com/troessner/reek/tree)
117
123
  * Read the code API at [http://rdoc.info/projects/troessner/reek](http://rdoc.info/projects/troessner/reek)
118
124
 
data/bin/reek CHANGED
@@ -6,6 +6,6 @@
6
6
  # Author: Kevin Rutherford
7
7
  #
8
8
 
9
- require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'lib', 'reek', 'cli', 'application')
9
+ require 'reek/cli/application'
10
10
 
11
11
  exit Reek::Cli::Application.new(ARGV).execute
@@ -1,120 +1,105 @@
1
- ---
2
- UncommunicativeParameterName:
3
- accept: []
4
-
1
+ ---
2
+ Attribute:
3
+ enabled: false
5
4
  exclude: []
6
-
5
+ BooleanParameter:
7
6
  enabled: true
8
- reject:
9
- - !ruby/regexp /^.$/
10
- - !ruby/regexp /[0-9]$/
11
- - !ruby/regexp /[A-Z]/
12
- LargeClass:
13
- max_methods: 25
14
7
  exclude: []
15
-
8
+ ClassVariable:
16
9
  enabled: true
17
- max_instance_variables: 9
18
- UncommunicativeMethodName:
19
- accept: []
20
-
21
10
  exclude: []
22
-
11
+ ControlParameter:
23
12
  enabled: true
24
- reject:
25
- - !ruby/regexp /^[a-z]$/
26
- - !ruby/regexp /[0-9]$/
27
- - !ruby/regexp /[A-Z]/
28
- LongParameterList:
29
- max_params: 3
30
13
  exclude: []
31
-
14
+ DataClump:
32
15
  enabled: true
33
- overrides:
34
- initialize:
35
- max_params: 5
36
- FeatureEnvy:
37
- exclude: &id001 []
38
-
16
+ exclude: []
17
+ max_copies: 2
18
+ min_clump_size: 2
19
+ DuplicateMethodCall:
39
20
  enabled: true
40
- ClassVariable:
41
- exclude: *id001
21
+ exclude: []
22
+ max_calls: 1
23
+ allow_calls: []
24
+ FeatureEnvy:
42
25
  enabled: true
43
- BooleanParameter:
44
- exclude: *id001
26
+ exclude: []
27
+ IrresponsibleModule:
45
28
  enabled: true
46
- IrresponsibleModule:
47
- exclude: *id001
29
+ exclude: []
30
+ LongParameterList:
48
31
  enabled: true
49
- UncommunicativeModuleName:
50
- accept:
51
- - Inline::C
52
32
  exclude: []
53
-
33
+ max_params: 3
34
+ overrides:
35
+ initialize:
36
+ max_params: 5
37
+ LongYieldList:
54
38
  enabled: true
55
- reject:
56
- - !ruby/regexp /^.$/
57
- - !ruby/regexp /[0-9]$/
58
- NestedIterators:
59
- ignore_iterators: []
60
-
61
39
  exclude: []
62
-
40
+ max_params: 3
41
+ NestedIterators:
63
42
  enabled: true
43
+ exclude: []
64
44
  max_allowed_nesting: 1
65
- LongMethod:
66
- max_statements: 5
67
- exclude:
68
- - initialize
45
+ ignore_iterators: []
46
+ NilCheck:
69
47
  enabled: true
70
- Duplication:
71
- allow_calls: []
72
-
73
48
  exclude: []
74
-
49
+ RepeatedConditional:
75
50
  enabled: true
76
- max_calls: 1
77
- UtilityFunction:
78
- max_helper_calls: 1
79
51
  exclude: []
80
-
52
+ max_ifs: 2
53
+ TooManyInstanceVariables:
81
54
  enabled: true
82
- Attribute:
83
55
  exclude: []
84
-
85
- enabled: false
86
- UncommunicativeVariableName:
87
- accept: []
88
-
56
+ max_instance_variables: 9
57
+ TooManyMethods:
58
+ enabled: true
89
59
  exclude: []
90
-
60
+ max_methods: 25
61
+ TooManyStatements:
91
62
  enabled: true
92
- reject:
93
- - !ruby/regexp /^.$/
63
+ exclude:
64
+ - initialize
65
+ max_statements: 5
66
+ UncommunicativeMethodName:
67
+ enabled: true
68
+ exclude: []
69
+ reject:
70
+ - !ruby/regexp /^[a-z]$/
94
71
  - !ruby/regexp /[0-9]$/
95
72
  - !ruby/regexp /[A-Z]/
96
- SimulatedPolymorphism:
97
- exclude: []
98
-
73
+ accept: []
74
+ UncommunicativeModuleName:
99
75
  enabled: true
100
- max_ifs: 2
101
- DataClump:
102
76
  exclude: []
103
-
104
- enabled: true
105
- max_copies: 2
106
- min_clump_size: 2
107
- ControlCouple:
108
- exclude: *id001
77
+ reject:
78
+ - !ruby/regexp /^.$/
79
+ - !ruby/regexp /[0-9]$/
80
+ accept:
81
+ - Inline::C
82
+ UncommunicativeParameterName:
109
83
  enabled: true
110
- LongYieldList:
111
- max_params: 3
112
84
  exclude: []
113
-
85
+ reject:
86
+ - !ruby/regexp /^.$/
87
+ - !ruby/regexp /[0-9]$/
88
+ - !ruby/regexp /[A-Z]/
89
+ accept: []
90
+ UncommunicativeVariableName:
114
91
  enabled: true
115
- UnusedParameters:
116
- exclude: *id001
92
+ exclude: []
93
+ reject:
94
+ - !ruby/regexp /^.$/
95
+ - !ruby/regexp /[0-9]$/
96
+ - !ruby/regexp /[A-Z]/
97
+ accept:
98
+ - _
99
+ UnusedParameters:
117
100
  enabled: true
118
- NilCheck:
119
- exclude: *id001
101
+ exclude: []
102
+ UtilityFunction:
120
103
  enabled: true
104
+ exclude: []
105
+ max_helper_calls: 1
@@ -43,18 +43,3 @@ Feature: Reek can be controlled using command-line options
43
43
  -y, --yaml Report smells in YAML format
44
44
 
45
45
  """
46
-
47
- Scenario: output line numbers if -n flag is passed
48
- When I run reek -n spec/samples/not_quite_masked/dirty.rb
49
- Then the exit status indicates smells
50
- And it should indicate the line numbers of those smells
51
- And it reports:
52
- """
53
- spec/samples/not_quite_masked/dirty.rb -- 5 warnings:
54
- [7]:Dirty has the variable name '@s' (UncommunicativeVariableName)
55
- [6, 8]:Dirty#a calls @s.title twice (DuplicateMethodCall)
56
- [6, 8]:Dirty#a calls puts(@s.title) twice (DuplicateMethodCall)
57
- [7]:Dirty#a contains iterators nested 2 deep (NestedIterators)
58
- [5]:Dirty#a has the name 'a' (UncommunicativeMethodName)
59
-
60
- """
@@ -56,3 +56,26 @@ Feature: Correctly formatted reports
56
56
  | option |
57
57
  | -q |
58
58
  | --quiet |
59
+ | -n -q |
60
+ | -q -n |
61
+
62
+ Scenario Outline: --line-number turns on line numbers
63
+ When I run reek <option> spec/samples/not_quite_masked/dirty.rb
64
+ Then the exit status indicates smells
65
+ And it reports:
66
+ """
67
+ spec/samples/not_quite_masked/dirty.rb -- 5 warnings:
68
+ [7]:Dirty has the variable name '@s' (UncommunicativeVariableName)
69
+ [6, 8]:Dirty#a calls @s.title twice (DuplicateMethodCall)
70
+ [6, 8]:Dirty#a calls puts(@s.title) twice (DuplicateMethodCall)
71
+ [7]:Dirty#a contains iterators nested 2 deep (NestedIterators)
72
+ [5]:Dirty#a has the name 'a' (UncommunicativeMethodName)
73
+
74
+ """
75
+
76
+ Examples:
77
+ | option |
78
+ | -n |
79
+ | --line-number |
80
+ | -n -q |
81
+ | -q -n |
@@ -10,7 +10,7 @@ Feature: Basic smell detection
10
10
  Then the exit status indicates smells
11
11
  And it reports:
12
12
  """
13
- spec/samples/inline.rb -- 42 warnings:
13
+ spec/samples/inline.rb -- 40 warnings:
14
14
  File has no descriptive comment (IrresponsibleModule)
15
15
  Inline declares the class variable @@directory (ClassVariable)
16
16
  Inline declares the class variable @@rootdir (ClassVariable)
@@ -28,7 +28,6 @@ Feature: Basic smell detection
28
28
  Inline::C#build calls io.puts 6 times (DuplicateMethodCall)
29
29
  Inline::C#build calls io.puts("#endif") twice (DuplicateMethodCall)
30
30
  Inline::C#build calls io.puts("#ifdef __cplusplus") twice (DuplicateMethodCall)
31
- Inline::C#build calls module_name twice (DuplicateMethodCall)
32
31
  Inline::C#build calls warn("Output:\n#{result}") twice (DuplicateMethodCall)
33
32
  Inline::C#build contains iterators nested 2 deep (NestedIterators)
34
33
  Inline::C#build has approx 60 statements (TooManyStatements)
@@ -41,7 +40,6 @@ Feature: Basic smell detection
41
40
  Inline::C#generate calls signature["args"].map twice (DuplicateMethodCall)
42
41
  Inline::C#generate has approx 32 statements (TooManyStatements)
43
42
  Inline::C#initialize calls stack.empty? twice (DuplicateMethodCall)
44
- Inline::C#load calls so_name twice (DuplicateMethodCall)
45
43
  Inline::C#module_name has the variable name 'm' (UncommunicativeVariableName)
46
44
  Inline::C#module_name has the variable name 'x' (UncommunicativeVariableName)
47
45
  Inline::C#parse_signature has approx 15 statements (TooManyStatements)
@@ -61,7 +59,7 @@ Feature: Basic smell detection
61
59
  Then the exit status indicates smells
62
60
  And it reports:
63
61
  """
64
- spec/samples/optparse.rb -- 115 warnings:
62
+ spec/samples/optparse.rb -- 109 warnings:
65
63
  OptionParser has at least 42 methods (TooManyMethods)
66
64
  OptionParser has the variable name 'f' (UncommunicativeVariableName)
67
65
  OptionParser has the variable name 'k' (UncommunicativeVariableName)
@@ -90,7 +88,6 @@ Feature: Basic smell detection
90
88
  OptionParser#make_switch calls q.downcase 3 times (DuplicateMethodCall)
91
89
  OptionParser#make_switch calls search(:atype, FalseClass) twice (DuplicateMethodCall)
92
90
  OptionParser#make_switch calls search(:atype, o) 6 times (DuplicateMethodCall)
93
- OptionParser#make_switch contains iterators nested 2 deep (NestedIterators)
94
91
  OptionParser#make_switch contains iterators nested 3 deep (NestedIterators)
95
92
  OptionParser#make_switch has approx 68 statements (TooManyStatements)
96
93
  OptionParser#make_switch has the variable name 'a' (UncommunicativeVariableName)
@@ -112,7 +109,6 @@ Feature: Basic smell detection
112
109
  OptionParser#parse_in_order calls setter.call(sw.switch_name, val) twice (DuplicateMethodCall)
113
110
  OptionParser#parse_in_order calls sw.block twice (DuplicateMethodCall)
114
111
  OptionParser#parse_in_order calls sw.switch_name twice (DuplicateMethodCall)
115
- OptionParser#parse_in_order contains iterators nested 2 deep (NestedIterators)
116
112
  OptionParser#parse_in_order contains iterators nested 3 deep (NestedIterators)
117
113
  OptionParser#parse_in_order has approx 28 statements (TooManyStatements)
118
114
  OptionParser#parse_in_order is controlled by argument setter (ControlParameter)
@@ -123,7 +119,6 @@ Feature: Basic smell detection
123
119
  OptionParser#summarize has 4 parameters (LongParameterList)
124
120
  OptionParser#summarize has the variable name 'l' (UncommunicativeVariableName)
125
121
  OptionParser#ver has the variable name 'v' (UncommunicativeVariableName)
126
- OptionParser::Arguable#initialize has unused parameter '*args' (UnusedParameters)
127
122
  OptionParser::CompletingHash#match contains iterators nested 2 deep (NestedIterators)
128
123
  OptionParser::Completion#complete calls candidates.size twice (DuplicateMethodCall)
129
124
  OptionParser::Completion#complete calls k.id2name twice (DuplicateMethodCall)
@@ -148,9 +143,7 @@ Feature: Basic smell detection
148
143
  OptionParser::List#update is controlled by argument sopts (ControlParameter)
149
144
  OptionParser::ParseError#set_option is controlled by argument eq (ControlParameter)
150
145
  OptionParser::Switch#add_banner has the variable name 's' (UncommunicativeVariableName)
151
- OptionParser::Switch#conv_arg calls conv twice (DuplicateMethodCall)
152
146
  OptionParser::Switch#initialize has 7 parameters (LongParameterList)
153
- OptionParser::Switch#parse_arg calls pattern twice (DuplicateMethodCall)
154
147
  OptionParser::Switch#parse_arg calls s.length twice (DuplicateMethodCall)
155
148
  OptionParser::Switch#parse_arg has approx 11 statements (TooManyStatements)
156
149
  OptionParser::Switch#parse_arg has the variable name 'm' (UncommunicativeVariableName)
@@ -158,7 +151,6 @@ Feature: Basic smell detection
158
151
  OptionParser::Switch#self.guess has the variable name 't' (UncommunicativeVariableName)
159
152
  OptionParser::Switch#self.incompatible_argument_styles has the parameter name 't' (UncommunicativeParameterName)
160
153
  OptionParser::Switch#summarize calls (indent + l) twice (DuplicateMethodCall)
161
- OptionParser::Switch#summarize calls arg 4 times (DuplicateMethodCall)
162
154
  OptionParser::Switch#summarize calls left.collect twice (DuplicateMethodCall)
163
155
  OptionParser::Switch#summarize calls left.collect { |s| s.length }.max twice (DuplicateMethodCall)
164
156
  OptionParser::Switch#summarize calls left.collect { |s| s.length }.max.to_i twice (DuplicateMethodCall)
@@ -185,7 +177,7 @@ Feature: Basic smell detection
185
177
  Then the exit status indicates smells
186
178
  And it reports:
187
179
  """
188
- spec/samples/redcloth.rb -- 102 warnings:
180
+ spec/samples/redcloth.rb -- 101 warnings:
189
181
  RedCloth has at least 44 methods (TooManyMethods)
190
182
  RedCloth has the variable name 'a' (UncommunicativeVariableName)
191
183
  RedCloth has the variable name 'b' (UncommunicativeVariableName)
@@ -210,7 +202,6 @@ Feature: Basic smell detection
210
202
  RedCloth#block_textile_lists has the variable name 'i' (UncommunicativeVariableName)
211
203
  RedCloth#block_textile_lists has the variable name 'v' (UncommunicativeVariableName)
212
204
  RedCloth#block_textile_lists refers to depth more than self (FeatureEnvy)
213
- RedCloth#block_textile_table contains iterators nested 2 deep (NestedIterators)
214
205
  RedCloth#block_textile_table contains iterators nested 3 deep (NestedIterators)
215
206
  RedCloth#block_textile_table has approx 18 statements (TooManyStatements)
216
207
  RedCloth#block_textile_table has the variable name 'x' (UncommunicativeVariableName)
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Reek's core functionality
3
3
  #
4
- require File.join(File.dirname(File.expand_path(__FILE__)), 'reek', 'version')
5
- require File.join(File.dirname(File.expand_path(__FILE__)), 'reek', 'examiner')
6
- require File.join(File.dirname(File.expand_path(__FILE__)), 'reek', 'smell_warning')
4
+ require 'reek/version'
5
+ require 'reek/examiner'
6
+ require 'reek/smell_warning'
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(File.expand_path(__FILE__)), 'command_line')
1
+ require 'reek/cli/command_line'
2
2
 
3
3
  module Reek
4
4
  module Cli
@@ -1,10 +1,10 @@
1
1
  require 'optparse'
2
- require File.join(File.dirname(File.expand_path(__FILE__)), 'report')
3
- require File.join(File.dirname(File.expand_path(__FILE__)), 'reek_command')
4
- require File.join(File.dirname(File.expand_path(__FILE__)), 'help_command')
5
- require File.join(File.dirname(File.expand_path(__FILE__)), 'version_command')
6
- require File.join(File.dirname(File.expand_path(__FILE__)), 'yaml_command')
7
- require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'source')
2
+ require 'reek/cli/report'
3
+ require 'reek/cli/reek_command'
4
+ require 'reek/cli/help_command'
5
+ require 'reek/cli/version_command'
6
+ require 'reek/cli/yaml_command'
7
+ require 'reek/source'
8
8
 
9
9
  module Reek
10
10
  module Cli
@@ -18,6 +18,7 @@ module Reek
18
18
  @argv = argv
19
19
  @parser = OptionParser.new
20
20
  @report_class = VerboseReport
21
+ @warning_formatter = SimpleWarningFormatter
21
22
  @command_class = ReekCommand
22
23
  @config_files = []
23
24
  set_options
@@ -75,7 +76,7 @@ EOB
75
76
  @report_class = opt ? QuietReport : VerboseReport
76
77
  end
77
78
  @parser.on("-n", "--line-number", "Prefix the output with the line number(s).") do
78
- @report_class = ShowLineReport
79
+ @warning_formatter = WarningFormatterWithLineNumbers
79
80
  end
80
81
  @parser.on("-y", "--yaml", "Report smells in YAML format") do
81
82
  @command_class = YamlCommand
@@ -96,7 +97,8 @@ EOB
96
97
  if @command_class == YamlCommand
97
98
  YamlCommand.create(sources, @config_files)
98
99
  else
99
- ReekCommand.create(sources, @report_class, @config_files)
100
+ report = @report_class.new(@warning_formatter)
101
+ ReekCommand.create(sources, report, @config_files)
100
102
  end
101
103
  end
102
104
  end