flog 4.3.2 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c488f428a039d38dd1263898d31c8c0fa0797b1
4
- data.tar.gz: a34343c3166a0976e863fd400622e64283331230
3
+ metadata.gz: 25fa9b8cb31c93fceda987510781fe35652fde29
4
+ data.tar.gz: af74743f09f07af514a3a0f449eafd2ed0491b8f
5
5
  SHA512:
6
- metadata.gz: 4a6f64d1b22c3bf419ad1810ddb33ead999fca60751f718b584bed2da4a73da5c29ce5ce432f5977cb8942c6a021c236b87e097bdde9ae5b439c3d9edcb9c969
7
- data.tar.gz: ecf3a6ff9166e6b3b4493e99b406f8006643d9ae777b424929bcd5f365ff329a05296a1f43004441c419f43b850af8bd9f8a8f16ae1a69aa241906f31dbc9770
6
+ metadata.gz: 43271946cdbbb803730059201ac21e1ba3c83764256b54251a6b7fd5e97eaf14fa810636e25e77b5182b6f135bf4b872b76f1ceb2180b2fc749f7fe47f5d99f0
7
+ data.tar.gz: d68f5e52e637dd54597c28e980b97874e148f67986ca33fffc03541a84512f106ada386fe483c43e87d852ec843e6d2466ebd9db4e35eb690c8b76062ed77f97
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,4 @@
1
-
2
- C�jm�;�4�wK��s�i��/8�äi� �a���c��Xc�p2B{O��[��7����e�������8]�Ó�ebF0���>]3�<J�?sh�U�"O�*�-ET͎�j&��8)v �s���F��� O�P��W �5�*&���Ќ�Y9}��X[�]�KNw(R}͓� ���B�u��V�*�O�>�K| ����C�B%>�.P�G�:u Dh�iu�j�ewǸ��4*?dM��u �
1
+ :�1�_�6���;b3���uc��^C悽4��C��|�
2
+ }���>��/K��/Hέc4�͉�7�����).
3
+ �Ek�����Z�x���4]G3V!(iz�y��v���!����"�Y�i��k��'LP}�'E�d�%&^CU��+.U��x�=�ܛ��rԌޠ�}�{�/�AƊN��S:��URs�� 8�Qq���sc�{���(�� �GAy]W��
4
+ ��P�-������.j����
data.tar.gz.sig CHANGED
Binary file
data/.autotest CHANGED
@@ -6,6 +6,7 @@ require 'autotest/rcov' if ENV['RCOV']
6
6
  Autotest.add_hook :initialize do |at|
7
7
  at.libs << ":../../ruby_parser/dev/lib"
8
8
  at.libs << ":../../sexp_processor/dev/lib"
9
+ at.libs << ":../../path_expander/dev/lib"
9
10
 
10
11
  at.add_mapping(/^spec\/.*_spec\.rb$/) do |filename, _|
11
12
  filename
@@ -1,3 +1,9 @@
1
+ === 4.4.0 / 2016-05-16
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Switched to path_expander to deal with cmdline args. See path_expander for details.
6
+
1
7
  === 4.3.2 / 2015-01-30
2
8
 
3
9
  * 1 bug fix:
data/Manifest.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  .autotest
2
- History.txt
2
+ History.rdoc
3
3
  Manifest.txt
4
- README.txt
4
+ README.rdoc
5
5
  Rakefile
6
6
  bin/flog
7
7
  lib/flog.rb
@@ -13,6 +13,10 @@ report. The higher the score, the more pain the code is in.
13
13
  == FEATURES/PROBLEMS:
14
14
 
15
15
  * Easy to read reporting of complexity/pain.
16
+ * Uses path_expander, so you can use:
17
+ * dir_arg -- expand a directory automatically
18
+ * @file_of_args -- persist arguments in a file
19
+ * -path_to_subtract -- ignore intersecting subsets of files/directories
16
20
 
17
21
  == SYNOPSIS:
18
22
 
@@ -27,8 +31,9 @@ report. The higher the score, the more pain the code is in.
27
31
 
28
32
  == REQUIREMENTS:
29
33
 
30
- * ruby2ruby (only for -v)
34
+ * ruby2ruby (soft dependency: only for -v)
31
35
  * ruby_parser
36
+ * path_expander
32
37
 
33
38
  == INSTALL:
34
39
 
data/Rakefile CHANGED
@@ -8,9 +8,11 @@ Hoe.add_include_dirs("../../ruby_parser/dev/lib",
8
8
  "../../sexp_processor/dev/lib",
9
9
  "../../ZenTest/dev/lib",
10
10
  "../../minitest/dev/lib",
11
+ "../../path_expander/dev/lib",
11
12
  "lib")
12
13
 
13
14
  Hoe.plugin :seattlerb
15
+ Hoe.plugin :rdoc
14
16
 
15
17
  Hoe.spec 'flog' do
16
18
  developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
@@ -20,6 +22,7 @@ Hoe.spec 'flog' do
20
22
 
21
23
  dependency "sexp_processor", "~> 4.4"
22
24
  dependency "ruby_parser", ["~> 3.1", "> 3.1.0"]
25
+ dependency "path_expander", "~> 1.0"
23
26
  end
24
27
 
25
28
  task :debug do
data/bin/flog CHANGED
@@ -2,14 +2,6 @@
2
2
 
3
3
  require "flog_cli"
4
4
 
5
- FlogCLI.load_plugins
6
-
7
- options = FlogCLI.parse_options ARGV
8
-
9
- ARGV << "-" if ARGV.empty?
10
-
11
- flogger = FlogCLI.new options
12
- flogger.flog ARGV
13
- flogger.report
5
+ FlogCLI.run
14
6
 
15
7
  exit 0
data/lib/flog.rb CHANGED
@@ -11,7 +11,7 @@ class File
11
11
  end
12
12
 
13
13
  class Flog < MethodBasedSexpProcessor
14
- VERSION = "4.3.2" # :nodoc:
14
+ VERSION = "4.4.0" # :nodoc:
15
15
 
16
16
  ##
17
17
  # Cut off point where the report should stop unless --all given.
@@ -166,7 +166,7 @@ class Flog < MethodBasedSexpProcessor
166
166
  # Flog the given files. Deals with "-", and syntax errors.
167
167
  #
168
168
  # Not as smart as FlogCLI's #flog method as it doesn't traverse
169
- # dirs. Use FlogCLI.expand_dirs_to_files or see FlogCLI#flog.
169
+ # dirs. Use PathExpander to expand dirs into files.
170
170
 
171
171
  def flog(*files)
172
172
  files.each do |file|
data/lib/flog_cli.rb CHANGED
@@ -2,6 +2,7 @@ require "rubygems"
2
2
  require "optparse"
3
3
  require "forwardable"
4
4
 
5
+ require "path_expander"
5
6
  require "flog"
6
7
 
7
8
  class FlogCLI
@@ -12,21 +13,17 @@ class FlogCLI
12
13
  def_delegators :@flog, :threshold, :total_score, :no_method, :calculate_total_scores
13
14
  def_delegators :@flog, :max_method
14
15
 
15
- ##
16
- # Expands +*dirs+ to all files within that match ruby and rake extensions.
17
- # --
18
- # REFACTOR: from flay
16
+ def self.run args = ARGV
17
+ load_plugins
19
18
 
20
- def self.expand_dirs_to_files *dirs
21
- extensions = %w[rb rake]
19
+ expander = PathExpander.new args, "**/*.{rb,rake}"
20
+ files = expander.process
22
21
 
23
- dirs.flatten.map { |p|
24
- if File.directory? p then
25
- Dir[File.join(p, '**', "*.{#{extensions.join(',')}}")]
26
- else
27
- p
28
- end
29
- }.flatten.sort
22
+ options = parse_options args
23
+
24
+ flogger = new options
25
+ flogger.flog(*files)
26
+ flogger.report
30
27
  end
31
28
 
32
29
  ##
@@ -157,11 +154,12 @@ class FlogCLI
157
154
  end
158
155
 
159
156
  ##
160
- # Flog the given files or directories. Smart. Deals with "-", syntax
161
- # errors, and traversing subdirectories intelligently.
157
+ # Flog the given files. Deals with "-", syntax errors, and
158
+ # traversing subdirectories intelligently. Use PathExpander to
159
+ # process dirs into files.
162
160
 
163
- def flog(*files_or_dirs)
164
- files = FlogCLI.expand_dirs_to_files(*files_or_dirs)
161
+ def flog(*files)
162
+ files << "-" if files.empty?
165
163
  @flog.flog(*files)
166
164
  end
167
165
 
data/lib/flog_task.rb CHANGED
@@ -53,7 +53,11 @@ class FlogTask < Rake::TaskLib
53
53
  task name do
54
54
  require "flog_cli"
55
55
  flog = FlogCLI.new :continue => true, :quiet => true, :methods => @methods_only
56
- flog.flog(*dirs)
56
+
57
+ expander = PathExpander.new dirs, "**/*.{rb,rake}"
58
+ files = expander.process
59
+
60
+ flog.flog(*files)
57
61
 
58
62
  desc, score = flog.send method
59
63
  desc, score = "total", desc unless score # total only returns a number
data/test/test_flog.rb CHANGED
@@ -38,7 +38,7 @@ class TestFlog < FlogTest
38
38
  def test_average
39
39
  test_process_and
40
40
 
41
- assert_equal 1.0, @flog.average
41
+ assert_in_epsilon 1.0, @flog.average
42
42
  end
43
43
 
44
44
  def test_flog
@@ -47,7 +47,7 @@ class TestFlog < FlogTest
47
47
  exp = { "main#none" => { :+ => 1.0, :lit_fixnum => 0.6 } }
48
48
  assert_equal exp, @flog.calls
49
49
 
50
- assert_equal 1.6, @flog.total_score unless @flog.option[:methods]
50
+ assert_in_epsilon 1.6, @flog.total_score unless @flog.option[:methods]
51
51
  assert_equal 3, @flog.mass["-"]
52
52
  end
53
53
 
@@ -61,7 +61,7 @@ class TestFlog < FlogTest
61
61
  exp = { "main#none" => { :+ => 1.0, :lit_fixnum => 0.6 } }
62
62
  assert_equal exp, @flog.calls
63
63
 
64
- assert_equal 1.6, @flog.total_score unless @flog.option[:methods]
64
+ assert_in_epsilon 1.6, @flog.total_score unless @flog.option[:methods]
65
65
  assert_equal 3, @flog.mass[file]
66
66
  end
67
67
 
@@ -81,11 +81,11 @@ class TestFlog < FlogTest
81
81
  end
82
82
 
83
83
  def test_penalize_by
84
- assert_equal 1, @flog.multiplier
84
+ assert_in_epsilon 1, @flog.multiplier
85
85
  @flog.penalize_by 2 do
86
- assert_equal 3, @flog.multiplier
86
+ assert_in_epsilon 3, @flog.multiplier
87
87
  end
88
- assert_equal 1, @flog.multiplier
88
+ assert_in_epsilon 1, @flog.multiplier
89
89
  end
90
90
 
91
91
  def test_process_alias
@@ -461,18 +461,18 @@ class TestFlog < FlogTest
461
461
  end
462
462
 
463
463
  def test_score_method
464
- assert_equal 3.0, @flog.score_method(:blah => 3.0)
465
- assert_equal 4.0, @flog.score_method(:assignment => 4.0)
466
- assert_equal 2.0, @flog.score_method(:branch => 2.0)
467
- assert_equal 5.0, @flog.score_method(:blah => 3.0, # distance formula
468
- :branch => 4.0)
464
+ assert_in_epsilon 3.0, @flog.score_method(:blah => 3.0)
465
+ assert_in_epsilon 4.0, @flog.score_method(:assignment => 4.0)
466
+ assert_in_epsilon 2.0, @flog.score_method(:branch => 2.0)
467
+ assert_in_epsilon 5.0, @flog.score_method(:blah => 3.0, # distance formula
468
+ :branch => 4.0)
469
469
  end
470
470
 
471
471
  def test_total_score
472
472
  @flog.add_to_score "blah", 2
473
473
  @flog.calculate_total_scores
474
474
 
475
- assert_equal 2.0, @flog.total_score
475
+ assert_in_epsilon 2.0, @flog.total_score
476
476
  end
477
477
 
478
478
  def test_max_method
@@ -494,7 +494,7 @@ class TestFlog < FlogTest
494
494
  }
495
495
  @flog.calculate_total_scores
496
496
 
497
- assert_equal 16.0, @flog.max_score
497
+ assert_in_epsilon 16.0, @flog.max_score
498
498
  end
499
499
 
500
500
  def assert_hash_in_epsilon exp, act
@@ -527,7 +527,7 @@ class TestFlog < FlogTest
527
527
 
528
528
  def test_threshold
529
529
  test_flog
530
- assert_equal Flog::THRESHOLD * 1.6, @flog.threshold
530
+ assert_in_epsilon Flog::THRESHOLD * 1.6, @flog.threshold
531
531
  end
532
532
 
533
533
  def test_no_threshold
@@ -561,8 +561,8 @@ class TestFlog < FlogTest
561
561
 
562
562
  assert_equal({ 'User#blah' => 'user.rb:3' }, @flog.method_locations)
563
563
  assert_equal({ "User#blah" => 2.2 }, @flog.totals)
564
- assert_equal(2.2, @flog.total_score)
565
- assert_equal(1.0, @flog.multiplier)
564
+ assert_in_epsilon(2.2, @flog.total_score)
565
+ assert_in_epsilon(1.0, @flog.multiplier)
566
566
  assert_equal({ "User#blah" => { :* => 1.2, :puts => 1.0 } }, @flog.calls)
567
567
  assert_equal({ "User" => 2.2 }, @flog.scores)
568
568
 
@@ -583,8 +583,8 @@ class TestFlog < FlogTest
583
583
 
584
584
  assert_equal({ 'Coder#happy?' => 'coder.rb:3' }, @flog.method_locations)
585
585
  assert_equal({ "Coder#happy?" => 1.0 }, @flog.totals)
586
- assert_equal(1.0, @flog.total_score)
587
- assert_equal(1.0, @flog.multiplier)
586
+ assert_in_epsilon(1.0, @flog.total_score)
587
+ assert_in_epsilon(1.0, @flog.multiplier)
588
588
  assert_equal({ "Coder#happy?" => { :sample => 1.0 } }, @flog.calls)
589
589
  assert_equal({ "Coder" => 1.0 }, @flog.scores)
590
590
  end
@@ -12,13 +12,6 @@ class TestFlogCLI < FlogTest
12
12
  @flog = FlogCLI.new :parser => RubyParser
13
13
  end
14
14
 
15
- def test_cls_expand_dirs_to_files
16
- expected = %w(lib/flog.rb lib/flog_cli.rb lib/flog_task.rb lib/gauntlet_flog.rb)
17
- assert_equal expected, FlogCLI.expand_dirs_to_files('lib')
18
- expected = %w(Rakefile)
19
- assert_equal expected, FlogCLI.expand_dirs_to_files('Rakefile')
20
- end
21
-
22
15
  def test_cls_parse_options
23
16
  # defaults
24
17
  opts = FlogCLI.parse_options
@@ -92,7 +85,7 @@ class TestFlogCLI < FlogTest
92
85
  expected = "\n 1.6: main#none\n"
93
86
 
94
87
  assert_equal expected, o.string
95
- assert_equal 1.6, @flog.totals["main#none"]
88
+ assert_in_epsilon 1.6, @flog.totals["main#none"]
96
89
  end
97
90
 
98
91
  def test_output_details_grouped
@@ -134,7 +127,7 @@ class TestFlogCLI < FlogTest
134
127
  "
135
128
 
136
129
  assert_equal expected, o.string
137
- assert_equal 1.6, @flog.totals["main#none"]
130
+ assert_in_epsilon 1.6, @flog.totals["main#none"]
138
131
  end
139
132
 
140
133
  def test_report
@@ -165,7 +158,7 @@ class TestFlogCLI < FlogTest
165
158
  @flog.option[:all] = true
166
159
  @flog.calculate_total_scores
167
160
 
168
- assert_equal 1.6, @flog.total_score unless @flog.option[:methods]
161
+ assert_in_epsilon 1.6, @flog.total_score unless @flog.option[:methods]
169
162
  assert_equal 3, @flog.mass["-"]
170
163
 
171
164
  o = StringIO.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flog
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.2
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBAjANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBAzANBgkq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pZa4P8H8gR8zme5kISwQrG80MbpqJV6/G3/ZicRFhN5sjwu0uHGue
26
+ bd9Cymf6oIRwHVarJux2M32T6bL07Hmi07w2QaPc3MnMKB/D46SRZ2JSSGPFRBTc
27
+ SilobMRoGs/7B15uGFUEnNrCB/ltMqhwwSx1r++UQPfeySHEV9uqu03E5Vb7J37O
28
+ 2Er6PLXHRiYsIycD1LkMi6YnixdITRHmrqJYE2rsjaIfpIehiusVAPHkNf7qbpHq
29
+ qx3h45R1CAsObX0SQDIT+rRbQrtKz1GHIZTOFYvEJjUY1XmRTZupD3CJ8Q7sDqSy
30
+ NLq5jm1fq6Y9Uolu3RJbmycf
31
31
  -----END CERTIFICATE-----
32
- date: 2015-01-30 00:00:00.000000000 Z
32
+ date: 2016-05-16 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
@@ -66,19 +66,19 @@ dependencies:
66
66
  - !ruby/object:Gem::Version
67
67
  version: 3.1.0
68
68
  - !ruby/object:Gem::Dependency
69
- name: minitest
69
+ name: path_expander
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ~>
73
73
  - !ruby/object:Gem::Version
74
- version: '5.5'
75
- type: :development
74
+ version: '1.0'
75
+ type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ~>
80
80
  - !ruby/object:Gem::Version
81
- version: '5.5'
81
+ version: '1.0'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rdoc
84
84
  requirement: !ruby/object:Gem::Requirement
@@ -99,14 +99,14 @@ dependencies:
99
99
  requirements:
100
100
  - - ~>
101
101
  - !ruby/object:Gem::Version
102
- version: '3.13'
102
+ version: '3.15'
103
103
  type: :development
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: '3.13'
109
+ version: '3.15'
110
110
  description: |-
111
111
  Flog reports the most tortured code in an easy to read pain
112
112
  report. The higher the score, the more pain the code is in.
@@ -116,15 +116,14 @@ executables:
116
116
  - flog
117
117
  extensions: []
118
118
  extra_rdoc_files:
119
- - History.txt
119
+ - History.rdoc
120
120
  - Manifest.txt
121
- - README.txt
121
+ - README.rdoc
122
122
  files:
123
123
  - .autotest
124
- - .gemtest
125
- - History.txt
124
+ - History.rdoc
126
125
  - Manifest.txt
127
- - README.txt
126
+ - README.rdoc
128
127
  - Rakefile
129
128
  - bin/flog
130
129
  - lib/flog.rb
@@ -140,7 +139,7 @@ metadata: {}
140
139
  post_install_message:
141
140
  rdoc_options:
142
141
  - --main
143
- - README.txt
142
+ - README.rdoc
144
143
  require_paths:
145
144
  - lib
146
145
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -159,6 +158,4 @@ rubygems_version: 2.4.5
159
158
  signing_key:
160
159
  specification_version: 4
161
160
  summary: Flog reports the most tortured code in an easy to read pain report
162
- test_files:
163
- - test/test_flog.rb
164
- - test/test_flog_cli.rb
161
+ test_files: []
metadata.gz.sig CHANGED
Binary file
data/.gemtest DELETED
File without changes