flog 4.7.0 → 4.9.0

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
  SHA256:
3
- metadata.gz: bde1a28d5e030ce021a8f20e9d7e877714e2c91e030b7560c3da7337a8a1e916
4
- data.tar.gz: 6b4dffe1d2a47f688deb1665a0a31a4c9ef5b901add108aac37489c97cb8f7ee
3
+ metadata.gz: 7262d5d6a50a7734f984039e83079bdd31f2b58f1c43325485b8a19288b1fe04
4
+ data.tar.gz: f4049fc93e849c6c3c9f08c0778dd5f0e46dece30a65bbb44ffa2aa4b07d15c7
5
5
  SHA512:
6
- metadata.gz: 56c6a3005252c00d8d61257f35f6eb9bf3d07b232acb316ebf5807dee9144c6bc76f24478ba64a000885677e1ba04d3d0af5ad8677934f90a5f8a965a2227f87
7
- data.tar.gz: 876c48e4a05cf087fb924f5c10977870facdec0f07c3cabd09eccee03360fca82d19a3b5a708e2a9bd51cd57f109d525b29cc50d22399fac17df3062b0d3c272
6
+ metadata.gz: b6974339f191d9f1ac348707fd6e5efcf5fbf5bb453aa53d91d91f4933fe18f07f47cca5065a378da049c3703cc399edccc3ff621bc714c04e366d0da9036e62
7
+ data.tar.gz: 998f2be74a01618e3187d94340c97e0149dff71a02e5924dab23f6519fa5c905d601ba7cc7dfcdcb25fc4b39329bfaaf62a78fef672eea06a50f62cba9bd259d
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,21 @@
1
+ === 4.9.0 / 2025-12-11
2
+
3
+ * 2 minor enhancements:
4
+
5
+ * Bumped path_expander to 2.0.0.
6
+ * Switched to prism for ruby parsing. Use --legacy for RubyParser.
7
+
8
+ === 4.8.0 / 2023-09-28
9
+
10
+ * 2 minor enhancements:
11
+
12
+ * Added ability to pass down option overrides through Flog.run.
13
+ * Removed ancient File.binread alias.
14
+
15
+ * 1 bug fix:
16
+
17
+ * Added missing rdoc.
18
+
1
19
  === 4.7.0 / 2023-07-18
2
20
 
3
21
  * 3 minor enhancements:
data/Rakefile CHANGED
@@ -24,8 +24,8 @@ Hoe.spec 'flog' do
24
24
  license "MIT"
25
25
 
26
26
  dependency "sexp_processor", "~> 4.8"
27
- dependency "ruby_parser", ["~> 3.1", "> 3.1.0"]
28
- dependency "path_expander", "~> 1.0"
27
+ dependency "prism", "~> 1.5"
28
+ dependency "path_expander", "~> 2.0"
29
29
 
30
30
  dependency "minitest", "~> 5.0", :dev
31
31
  end
@@ -40,17 +40,19 @@ task :debug do
40
40
  file = ENV["F"]
41
41
  ruby = ENV["R"]
42
42
  details = ENV["D"]
43
+ continue = ENV["C"]
43
44
 
44
45
  flog = FlogCLI.new :parser => RubyParser
45
46
 
46
47
  flog.option[:details] = true if details
48
+ flog.option[:continue] = true if continue
47
49
 
48
50
  if file then
49
51
  if File.directory? file then # quick hack to get directory scanning going
50
52
  argv = [file]
51
53
  argv.unshift "-v" if ENV["V"]
52
54
 
53
- FlogCLI.run argv
55
+ FlogCLI.run argv, flog.option
54
56
  exit 0
55
57
  end
56
58
  flog.flog file
data/bin/flog CHANGED
@@ -1,6 +1,6 @@
1
- #!/usr/local/bin/ruby -w
1
+ #!/usr/bin/env -S ruby -w
2
2
 
3
- require "flog_cli"
3
+ require_relative "../lib/flog_cli"
4
4
 
5
5
  FlogCLI.run
6
6
 
data/lib/flog.rb CHANGED
@@ -1,17 +1,24 @@
1
1
  require "sexp_processor"
2
- require "ruby_parser"
2
+ require "prism"
3
+ require "prism/translation/ruby_parser"
3
4
  require "timeout"
4
5
 
5
- class File
6
- RUBY19 = "<3".respond_to? :encoding unless defined? RUBY19 # :nodoc:
7
-
8
- class << self
9
- alias :binread :read unless RUBY19
10
- end
6
+ class Prism::Translation::RubyParser # compatibility layer
7
+ def process(ruby, file, timeout=nil) =
8
+ Timeout.timeout(timeout) { parse ruby, file }
11
9
  end
12
10
 
11
+ ##
12
+ # Flog is a SexpProcessor that calculates a ABC (assignments,
13
+ # branches, conditionals) complexity metric with some ruby-aware
14
+ # enhancements and a compounding penalty for increasing depth.
15
+ #
16
+ # In essence, this calculates the most tortured code. The higher the
17
+ # score, the more pain the code is in and the harder it is to
18
+ # thoroughly test.
19
+
13
20
  class Flog < MethodBasedSexpProcessor
14
- VERSION = "4.7.0" # :nodoc:
21
+ VERSION = "4.9.0" # :nodoc:
15
22
 
16
23
  ##
17
24
  # Cut off point where the report should stop unless --all given.
@@ -208,7 +215,7 @@ class Flog < MethodBasedSexpProcessor
208
215
  # methods. Does not handle timeouts or syntax errors. See #flog_ruby.
209
216
 
210
217
  def flog_ruby! ruby, file="-", timeout = 10
211
- @parser = (option[:parser] || RubyParser).new
218
+ @parser = option[:parser].new
212
219
 
213
220
  warn "** flogging #{file}" if option[:verbose]
214
221
 
@@ -229,6 +236,7 @@ class Flog < MethodBasedSexpProcessor
229
236
  @mass = {}
230
237
  @parser = nil
231
238
  @threshold = option[:threshold] || DEFAULT_THRESHOLD
239
+ option[:parser] ||= Prism::Translation::RubyParser
232
240
  self.auto_shift_type = true
233
241
  self.reset
234
242
  end
data/lib/flog_cli.rb CHANGED
@@ -5,6 +5,10 @@ require "forwardable"
5
5
  require "path_expander"
6
6
  require "flog"
7
7
 
8
+ ##
9
+ # This is the CLI interface for Flog, responsible for processing
10
+ # options, finding files, loading plugins, and reporting results.
11
+
8
12
  class FlogCLI
9
13
  extend Forwardable
10
14
 
@@ -13,13 +17,16 @@ class FlogCLI
13
17
  def_delegators :@flog, :threshold, :total_score, :no_method, :calculate_total_scores
14
18
  def_delegators :@flog, :max_method
15
19
 
16
- def self.run args = ARGV
20
+ ##
21
+ # This kicks off the whole thing.
22
+
23
+ def self.run args = ARGV, extra = {}
17
24
  load_plugins
18
25
 
19
26
  expander = PathExpander.new args, "**/*.{rb,rake}"
20
- files = expander.process
27
+ files = expander.process.to_a
21
28
 
22
- options = parse_options args
29
+ options = parse_options args, extra
23
30
 
24
31
  abort "no files or stdin (-) to process, aborting." if
25
32
  files.empty? and args.empty?
@@ -66,12 +73,12 @@ class FlogCLI
66
73
  ##
67
74
  # Parse options in +args+ (defaults to ARGV).
68
75
 
69
- def self.parse_options args = ARGV
76
+ def self.parse_options args = ARGV, extra_options = {}
70
77
  option = {
71
78
  :quiet => false,
72
79
  :continue => false,
73
- :parser => RubyParser,
74
- }
80
+ :parser => nil,
81
+ }.merge extra_options
75
82
 
76
83
  OptionParser.new do |opts|
77
84
  opts.separator "Standard options:"
@@ -123,6 +130,11 @@ class FlogCLI
123
130
  option[:score] = true
124
131
  end
125
132
 
133
+ opts.on "--legacy" "Use RubyParser for parsing." do
134
+ require "ruby_parser"
135
+ option[:parser] = RubyParser
136
+ end
137
+
126
138
  opts.on("-tN", "--threshold=N", Integer, "Set the report cutoff threshold (def: 60%).") do |n|
127
139
  option[:threshold] = n / 100.0
128
140
  end
data/lib/flog_task.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  require 'rake/tasklib'
2
2
 
3
+ ##
4
+ # A rake front-end for flog, allowing task creation with options for
5
+ # verbosity, reporting, and a failure threshold.
6
+
3
7
  class FlogTask < Rake::TaskLib
4
8
  ##
5
9
  # The name of the task. Defaults to :flog
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,18 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flog
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0
4
+ version: 4.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
12
11
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBBzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
12
+ MIIDPjCCAiagAwIBAgIBCTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
13
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVy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fXvNN6MT0nLChPyIYauT6SZZxubwJrUfA
26
+ 7R0c2CJTIboZ0XaGpLsXqHEF1c29H7TV1QvVuqKAN2mCjh4N82QVn+ZKtys28AwT
27
+ 6GfQX2fqLoi4KSc7xIzHKaNzqxeOICmJofk9w5VZ2rRN6yes8jvFYwz9HR41wdj8
28
+ bwfinv7Yp5fA6AysuZLhCykyfDuZVRrUp0Vb68YCKsLjJly/Theak+euNTxvHsB+
29
+ al9oSgPPHICMEX65qvLywitx
31
30
  -----END CERTIFICATE-----
32
- date: 2023-07-18 00:00:00.000000000 Z
31
+ date: 1980-01-02 00:00:00.000000000 Z
33
32
  dependencies:
34
33
  - !ruby/object:Gem::Dependency
35
34
  name: sexp_processor
@@ -46,39 +45,33 @@ dependencies:
46
45
  - !ruby/object:Gem::Version
47
46
  version: '4.8'
48
47
  - !ruby/object:Gem::Dependency
49
- name: ruby_parser
48
+ name: prism
50
49
  requirement: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '3.1'
55
- - - ">"
56
- - !ruby/object:Gem::Version
57
- version: 3.1.0
53
+ version: '1.5'
58
54
  type: :runtime
59
55
  prerelease: false
60
56
  version_requirements: !ruby/object:Gem::Requirement
61
57
  requirements:
62
58
  - - "~>"
63
59
  - !ruby/object:Gem::Version
64
- version: '3.1'
65
- - - ">"
66
- - !ruby/object:Gem::Version
67
- version: 3.1.0
60
+ version: '1.5'
68
61
  - !ruby/object:Gem::Dependency
69
62
  name: path_expander
70
63
  requirement: !ruby/object:Gem::Requirement
71
64
  requirements:
72
65
  - - "~>"
73
66
  - !ruby/object:Gem::Version
74
- version: '1.0'
67
+ version: '2.0'
75
68
  type: :runtime
76
69
  prerelease: false
77
70
  version_requirements: !ruby/object:Gem::Requirement
78
71
  requirements:
79
72
  - - "~>"
80
73
  - !ruby/object:Gem::Version
81
- version: '1.0'
74
+ version: '2.0'
82
75
  - !ruby/object:Gem::Dependency
83
76
  name: minitest
84
77
  requirement: !ruby/object:Gem::Requirement
@@ -119,14 +112,14 @@ dependencies:
119
112
  requirements:
120
113
  - - "~>"
121
114
  - !ruby/object:Gem::Version
122
- version: '4.0'
115
+ version: '4.3'
123
116
  type: :development
124
117
  prerelease: false
125
118
  version_requirements: !ruby/object:Gem::Requirement
126
119
  requirements:
127
120
  - - "~>"
128
121
  - !ruby/object:Gem::Version
129
- version: '4.0'
122
+ version: '4.3'
130
123
  description: |-
131
124
  Flog reports the most tortured code in an easy to read pain
132
125
  report. The higher the score, the more pain the code is in.
@@ -158,7 +151,6 @@ licenses:
158
151
  metadata:
159
152
  homepage_uri: http://ruby.sadi.st/
160
153
  source_code_uri: https://github.com/seattlerb/flog
161
- post_install_message:
162
154
  rdoc_options:
163
155
  - "--main"
164
156
  - README.rdoc
@@ -175,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
167
  - !ruby/object:Gem::Version
176
168
  version: '0'
177
169
  requirements: []
178
- rubygems_version: 3.4.10
179
- signing_key:
170
+ rubygems_version: 3.7.2
180
171
  specification_version: 4
181
172
  summary: Flog reports the most tortured code in an easy to read pain report
182
173
  test_files: []
metadata.gz.sig CHANGED
Binary file