feature_map 1.2.8 → 1.3.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.
@@ -1,7 +1,6 @@
1
1
  # @feature Metrics Calculation
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'rubocop'
5
4
  module FeatureMap
6
5
  module Private
7
6
  class FeatureMetricsCalculator
@@ -25,8 +24,8 @@ module FeatureMap
25
24
  metrics = file_paths.map { |file| calculate_for_file(file) }
26
25
 
27
26
  # Handle numeric metrics
28
- aggregate_metrics = [ABC_SIZE_METRIC, CYCLOMATIC_COMPLEXITY_METRIC, LINES_OF_CODE_METRIC].each_with_object({}) do |metric_key, agg|
29
- agg[metric_key] = metrics.sum { |m| m[metric_key] || 0 }
27
+ aggregate_metrics = [ABC_SIZE_METRIC, CYCLOMATIC_COMPLEXITY_METRIC, LINES_OF_CODE_METRIC].to_h do |metric_key|
28
+ [metric_key, metrics.sum { |m| m[metric_key] || 0 }]
30
29
  end
31
30
 
32
31
  # Handle additional supported metrics
@@ -47,6 +46,10 @@ module FeatureMap
47
46
 
48
47
  return metrics unless file_path.end_with?('.rb')
49
48
 
49
+ # Lazy load the rubocop gem only when we need to process AST nodes to avoid introducing unnecessary
50
+ # dependencies for use cases that do not exercise this functionality.
51
+ require 'rubocop'
52
+
50
53
  file_content = File.read(file_path)
51
54
  source = RuboCop::ProcessedSource.new(file_content, RUBY_VERSION.to_f)
52
55
  return metrics unless source.ast
@@ -1,8 +1,6 @@
1
1
  # @feature Metrics Calculation
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'parser/current'
5
-
6
4
  module FeatureMap
7
5
  module Private
8
6
  class LinesOfCodeCalculator
@@ -5,8 +5,8 @@ module FeatureMap
5
5
  class << self
6
6
  def map_tests_by_assignment(test_suites, assignments)
7
7
  # Transform test suites into a hash of filepath => assertion results
8
- tests_by_path = test_suites.each_with_object({}) do |suite, result|
9
- result[filepath(suite['name'])] = suite['assertionResults']
8
+ tests_by_path = test_suites.to_h do |suite|
9
+ [filepath(suite['name']), suite['assertionResults']]
10
10
  end
11
11
 
12
12
  assignments.each_with_object({}) do |(feature_name, files), result|
@@ -38,15 +38,15 @@ module FeatureMap
38
38
  end
39
39
 
40
40
  def self.generate_content(unit_by_feature, integration_by_feature, regression_by_feature)
41
- CodeFeatures.all.map(&:name).each_with_object({}) do |feature_name, content|
42
- content[feature_name] = {
41
+ CodeFeatures.all.map(&:name).to_h do |feature_name|
42
+ [feature_name, {
43
43
  'unit_count' => unit_by_feature.dig(feature_name, :count) || 0,
44
44
  'unit_pending' => unit_by_feature.dig(feature_name, :pending) || 0,
45
45
  'integration_count' => integration_by_feature.dig(feature_name, :count) || 0,
46
46
  'integration_pending' => integration_by_feature.dig(feature_name, :pending) || 0,
47
47
  'regression_count' => regression_by_feature.dig(feature_name, :count) || 0,
48
48
  'regression_pending' => regression_by_feature.dig(feature_name, :pending) || 0
49
- }
49
+ }]
50
50
  end
51
51
  end
52
52
 
data/lib/feature_map.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'set'
5
-
6
5
  require 'json'
7
6
  require 'yaml'
8
7
  require 'feature_map/commit'
@@ -138,12 +137,15 @@ module FeatureMap
138
137
  #
139
138
  # ./app/controllers/some_controller.rb:43:in `block (3 levels) in create'
140
139
  #
140
+ # Ruby 3.4 changed the opening quote around the function name from a
141
+ # backtick to a single quote (`block ...'` -> `'block ...'`), so both
142
+ # delimiters are matched to remain compatible across Ruby versions.
141
143
  backtrace_line = %r{\A(#{Pathname.pwd}/|\./)?
142
- (?<file>.+) # Matches 'app/controllers/some_controller.rb'
144
+ (?<file>.+) # Matches 'app/controllers/some_controller.rb'
143
145
  :
144
- (?<line>\d+) # Matches '43'
146
+ (?<line>\d+) # Matches '43'
145
147
  :in\s
146
- `(?<function>.*)' # Matches "`block (3 levels) in create'"
148
+ [`'](?<function>.*)' # Matches "`block (3 levels) in create'" or "'block (3 levels) in create'"
147
149
  \z}x
148
150
 
149
151
  backtrace.lazy.filter_map do |line|
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beyond Finance
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-06-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: code_ownership
@@ -52,6 +51,20 @@ dependencies:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: parser
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.3'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.3'
55
68
  - !ruby/object:Gem::Dependency
56
69
  name: rubocop
57
70
  requirement: !ruby/object:Gem::Requirement
@@ -247,7 +260,6 @@ metadata:
247
260
  source_code_uri: https://github.com/Beyond-Finance/feature_map
248
261
  changelog_uri: https://github.com/Beyond-Finance/feature_map/releases
249
262
  allowed_push_host: https://rubygems.org
250
- post_install_message:
251
263
  rdoc_options: []
252
264
  require_paths:
253
265
  - lib
@@ -262,8 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
274
  - !ruby/object:Gem::Version
263
275
  version: '0'
264
276
  requirements: []
265
- rubygems_version: 3.4.10
266
- signing_key:
277
+ rubygems_version: 3.6.9
267
278
  specification_version: 4
268
279
  summary: A gem to help identify and manage features within large Ruby and Rails applications
269
280
  test_files: []