reek 3.0.2 → 3.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: 71abe096497ff72ac2b0ff61c0264cde02d49ff3
4
- data.tar.gz: 03e5768e1b53aef97a23e47d985daceb3f7316dd
3
+ metadata.gz: d10cc19d7d47e9a5094aaf117aac55072abe9064
4
+ data.tar.gz: db2544839858ea0cad619f8bef26c77e0ebb9745
5
5
  SHA512:
6
- metadata.gz: 9e8b1c75ccd4d2982825ee6f066a834dc602b8d370179740d2a79645bd5ae1c3974ffb466560dc0e4962393f203efb7e8cb603afb22ebd37913d11eb91348c44
7
- data.tar.gz: c12a018c2777291fdcaaf93d3220b8d3abf193542cbe13763017c982473afa1e22767c3595cca3efe8e64c170954165b4a616412daff0822e1a053e0e8ed6fd5
6
+ metadata.gz: 0b29e3d3b6fcdcd5399b3d6faa881c88a226626589f5fff426c62e550c836b53b74280117a0dd9e362a9921b5fac4b2b86762714388d5a48ed425b0425c703e5
7
+ data.tar.gz: 7bc7a0108f69942487dc213fa76a5f43c09780d8c162151c0a66351aaa5520cafc2c4de5946050034827b3c6dcea5ad7abe728e709c6481efd62c0031df1b732
@@ -18,6 +18,10 @@ Metrics/MethodLength:
18
18
  Metrics/LineLength:
19
19
  Max: 100
20
20
 
21
+ # Indent one level for follow-up lines
22
+ Style/MultilineOperationIndentation:
23
+ EnforcedStyle: indented
24
+
21
25
  # Allow small arrays of words with quotes
22
26
  Style/WordArray:
23
27
  MinSize: 3
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 3.0.3
2
+
3
+ * (troessner) Fix finding sources when using just the current directory.
4
+
1
5
  == 3.0.2
2
6
 
3
7
  * (troessner) Only use ruby source files.
@@ -56,8 +56,8 @@ module Reek
56
56
 
57
57
  def exclude_paths
58
58
  @exclude_paths ||= @configuration.
59
- fetch(EXCLUDE_PATHS_KEY, []).
60
- map { |path| path.chomp('/') }
59
+ fetch(EXCLUDE_PATHS_KEY, []).
60
+ map { |path| path.chomp('/') }
61
61
  end
62
62
 
63
63
  private
@@ -18,7 +18,7 @@ module Reek
18
18
  def self.header(examiner)
19
19
  count = examiner.smells_count
20
20
  result = Rainbow("#{examiner.description} -- ").cyan +
21
- Rainbow("#{count} warning").yellow
21
+ Rainbow("#{count} warning").yellow
22
22
  result += Rainbow('s').yellow unless count == 1
23
23
  result
24
24
  end
@@ -66,7 +66,7 @@ module Reek
66
66
  def find_iters_for_iter_node(exp, depth)
67
67
  ignored = ignored_iterator? exp
68
68
  result = find_iters(exp.call, depth) +
69
- find_iters(exp.block, depth + (ignored ? 0 : 1))
69
+ find_iters(exp.block, depth + (ignored ? 0 : 1))
70
70
  result << [exp, depth] unless ignored
71
71
  result
72
72
  end
@@ -11,7 +11,9 @@ module Reek
11
11
  #
12
12
  # paths - a list of paths as Strings
13
13
  def initialize(paths)
14
- @paths = paths.map { |path| path.chomp('/') }
14
+ @pathnames = paths.
15
+ map { |path| Pathname.new(path.chomp('/')) }.
16
+ flat_map { |pathname| current_directory?(pathname) ? pathname.entries : pathname }
15
17
  end
16
18
 
17
19
  # Traverses all paths we initialized the SourceLocator with, finds
@@ -25,11 +27,9 @@ module Reek
25
27
  private
26
28
 
27
29
  def source_paths
28
- relevant_paths = []
29
- @paths.map do |given_path|
30
- print_no_such_file_error(given_path) && next unless path_exists?(given_path)
31
- Find.find(given_path) do |path|
32
- pathname = Pathname.new(path)
30
+ @pathnames.each_with_object([]) do |given_pathname, relevant_paths|
31
+ print_no_such_file_error(given_pathname) && next unless path_exists?(given_pathname)
32
+ given_pathname.find do |pathname|
33
33
  if pathname.directory?
34
34
  ignore_path?(pathname) ? Find.prune : next
35
35
  else
@@ -37,7 +37,6 @@ module Reek
37
37
  end
38
38
  end
39
39
  end
40
- relevant_paths.flatten.sort
41
40
  end
42
41
 
43
42
  def path_excluded?(pathname)
@@ -61,7 +60,11 @@ module Reek
61
60
  end
62
61
 
63
62
  def ruby_file?(pathname)
64
- pathname.to_s.end_with?('.rb')
63
+ pathname.extname == '.rb'
64
+ end
65
+
66
+ def current_directory?(pathname)
67
+ ['.', './'].include? pathname.to_s
65
68
  end
66
69
  end
67
70
  end
@@ -3,6 +3,6 @@ module Reek
3
3
  # This module holds the Reek version informations
4
4
  #
5
5
  module Version
6
- STRING = '3.0.2'
6
+ STRING = '3.0.3'
7
7
  end
8
8
  end
@@ -16,7 +16,7 @@ RSpec.describe Reek::Source::SourceLocator do
16
16
  sources = described_class.new([path]).sources
17
17
 
18
18
  expect(sources.map(&:path)).
19
- not_to include(files_that_are_expected_to_be_ignored)
19
+ not_to include(*files_that_are_expected_to_be_ignored)
20
20
 
21
21
  expect(sources.map(&:path)).to eq expected_files
22
22
  end
@@ -37,7 +37,7 @@ RSpec.describe Reek::Source::SourceLocator do
37
37
  sources = described_class.new([path]).sources
38
38
 
39
39
  expect(sources.map(&:path).sort).
40
- not_to include(files_that_are_expected_to_be_ignored)
40
+ not_to include(*files_that_are_expected_to_be_ignored)
41
41
 
42
42
  expect(sources.map(&:path).sort).to eq [
43
43
  'spec/samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb'
@@ -62,10 +62,27 @@ RSpec.describe Reek::Source::SourceLocator do
62
62
  sources = described_class.new([path]).sources
63
63
 
64
64
  expect(sources.map(&:path)).
65
- not_to include(files_that_are_expected_to_be_ignored)
65
+ not_to include(*files_that_are_expected_to_be_ignored)
66
66
 
67
67
  expect(sources.map(&:path)).to eq expected_files
68
68
  end
69
69
  end
70
+
71
+ context 'passing "." or "./" as argument' do
72
+ let(:expected_files) do
73
+ [
74
+ 'spec/spec_helper.rb',
75
+ 'lib/reek.rb'
76
+ ]
77
+ end
78
+
79
+ it 'expands it correctly' do
80
+ sources_for_dot = described_class.new(['.']).sources
81
+ sources_for_dot_slash = described_class.new(['./']).sources
82
+
83
+ expect(sources_for_dot.map(&:path)).to include(*expected_files)
84
+ expect(sources_for_dot.map(&:path)).to eq(sources_for_dot_slash.map(&:path))
85
+ end
86
+ end
70
87
  end
71
88
  end
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: 3.0.2
4
+ version: 3.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-07-03 00:00:00.000000000 Z
13
+ date: 2015-07-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser