reek 2.0.2 → 2.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1877ecb6f7f04aa89c30beda81afb570a22b0edf
4
- data.tar.gz: 9bb692ec4755c9402ce8bfa596e7333be0755573
3
+ metadata.gz: a6f9a08539415ceecd74495e36b1a11235bfccf2
4
+ data.tar.gz: aa9edb39c1cae7f4c66e2ac41e7173b39f337b4f
5
5
  SHA512:
6
- metadata.gz: 16cd877bea8569bb5e55e30f825d076d62fa7a0a5f026fbf50f86150672f93517a881d71cd048670a3d2f029cacd88c27ceab2f21fe6aa65de2a0ce7995cb27f
7
- data.tar.gz: cfd0ba532e2870abc0794fa173274b811a6a19de8ecf5adfd3f741c55cfec7aa70dc1263f4d183f584fc4c4f682ec9eed5b4d323bc996f5c1e2c5e654e7a5e14
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)](http://travis-ci.org/troessner/reek?branch=master)
7
- [![Gem Version](https://badge.fury.io/rb/reek.png)](http://badge.fury.io/rb/reek)
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](http://inch-ci.org/github/troessner/reek.png)](http://inch-ci.org/github/troessner/reek)
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](http://stackoverflow.com/questions/tagged/reek)
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
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  # Reek examines Ruby source code for smells.
4
- # Visit http://wiki.github.com/troessner/reek for docs etc.
4
+ # Visit https://wiki.github.com/troessner/reek for docs etc.
5
5
  #
6
6
  # Author: Kevin Rutherford
7
7
  #
@@ -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 http://wiki.github.com/troessner/reek for detailed help.
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 is all enabled smells)
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 (this is the default)
45
- -V, --[no-]empty-headings Show headings for smell-free source files
46
- -U, --[no-]wiki-links Show link to related Reek wiki page for each smell
47
- -n, --[no-]line-numbers Show line numbers in the output (this is the default)
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)
@@ -15,7 +15,7 @@ module Reek
15
15
  STATUS_SMELLS = 2
16
16
 
17
17
  def initialize(argv)
18
- @status = STATUS_SUCCESS
18
+ @status = STATUS_SUCCESS
19
19
  options_parser = Options.new(argv)
20
20
  begin
21
21
  @options = options_parser.parse
@@ -45,7 +45,7 @@ module Reek
45
45
  #{program_name} -s lib
46
46
  cat my_class.rb | #{program_name}
47
47
 
48
- See http://wiki.github.com/troessner/reek for detailed help.
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 is all enabled smells)') do |smell|
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 (this is the default)') do |opt|
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 Reek wiki page for each smell') do |show_links|
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 (this is the default)') do |show_numbers|
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. Formatting
8
- # the individual warnings is handled by the warning formatter passed in.
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
- # pre-pended with the result of the passed-in location formatter.
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 Wiki to the basic message from
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(_options = {})
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(smells.map(&:yaml_hash))
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
 
@@ -4,7 +4,7 @@ module Reek
4
4
  module Configuration
5
5
  class ConfigFileException < StandardError; end
6
6
  #
7
- # Reeks singleton configuration instance.
7
+ # Reek's singleton configuration instance.
8
8
  #
9
9
  module AppConfiguration
10
10
  @configuration = {}
@@ -3,7 +3,7 @@ require 'pathname'
3
3
  module Reek
4
4
  module Configuration
5
5
  #
6
- # ConfigurationFileFinder is responsible for finding reeks configuration.
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.updated(:lvar))
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
@@ -36,7 +36,7 @@ module Reek
36
36
  # Name of reek task. Defaults to :reek.
37
37
  attr_writer :name
38
38
 
39
- # Path to reeks config file.
39
+ # Path to reek's config file.
40
40
  # Setting the REEK_CFG environment variable overrides this.
41
41
  attr_writer :config_file
42
42
 
@@ -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
@@ -43,7 +43,7 @@ module Reek
43
43
  #
44
44
  def examine_context(method_ctx)
45
45
  method_ctx.envious_receivers.map do |ref, occurs|
46
- target = ref.format_ruby
46
+ target = ref.to_s
47
47
  SmellWarning.new self,
48
48
  context: method_ctx.full_name,
49
49
  lines: [method_ctx.exp.line],
@@ -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 :zsuper nodes.
319
- module ZsuperNode
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
@@ -3,6 +3,6 @@ module Reek
3
3
  # This module holds the Reek version informations
4
4
  #
5
5
  module Version
6
- STRING = '2.0.2'
6
+ STRING = '2.0.3'
7
7
  end
8
8
  end
@@ -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 = 'http://wiki.github.com/troessner/reek'
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.2
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-03-15 00:00:00.000000000 Z
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: http://wiki.github.com/troessner/reek
414
+ homepage: https://wiki.github.com/troessner/reek
415
415
  licenses:
416
416
  - MIT
417
417
  metadata: {}