gitlab-labkit 1.3.1 → 1.3.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
  SHA256:
3
- metadata.gz: 888cc5479aac46e57a89719bf13d9403a83f4d92c4f6c2a280b4c71950fee250
4
- data.tar.gz: 2d5cc94125a609627065b10faa15a85eec3998285686db906a3ce1f54ed1f89d
3
+ metadata.gz: fd5d320e1c751f2fea87cb55e57c3353b1255c62a126e97eba24a60642c9e0e0
4
+ data.tar.gz: 543e2fcd663bf562cb23426f0903acbafcf7f2edb6738e12dcc420fdfd8e26aa
5
5
  SHA512:
6
- metadata.gz: bc655d31560edac3cc29db253c3ea9c20f5fddfc479ac6f76563d56dfd795f265b0119a4480fa9bd10f90c9652eba31f458625a48570b70119004e4bf8ff609f
7
- data.tar.gz: 992a1a49adecaf7a52bb4caaec4484dc8feddcfc88fc83a8ddb4ada3b0aca0f6b50de32bf6a64062c9380482958175ff237a037d3c61023e4e541cb1efbd2230
6
+ metadata.gz: af194fc50ac69e6136c8e849b3445ed8f99c53eb555745ef5c03cbc5f42fde12b0a8fa33bb402c1fc80895feb4e9fba4a5c49cf345c77be10cc977f92cb105c4
7
+ data.tar.gz: e0b1dd39d3002edd45eb722d0aebe86e800688d878ab5e3beb79d060f65d7a3637ef3d5fb6351b9d80d81156542dd25dc0e3c291c4b7ce0485a4114752e69644
@@ -38,25 +38,34 @@ module Labkit
38
38
  callsite_path = normalize_path(location.path)
39
39
  return data unless callsite_path
40
40
 
41
- all_fields = extract_string_keys(data)
42
41
  logger_class = self.class.name || 'AnonymousLogger'
43
42
 
44
- all_fields.each do |field|
45
- standard_field = Labkit::Fields::Deprecated.standard_field_for(field)
46
- next unless standard_field
43
+ deprecated_lookup = Labkit::Fields::Deprecated.all
44
+ if data.is_a?(Hash)
45
+ data.each_key do |key|
46
+ key_str = key.to_s
47
+ standard_field = deprecated_lookup[key_str]
48
+ next unless standard_field
47
49
 
48
- Registry.instance.record_offense(callsite_path, location.lineno, field, standard_field, logger_class)
50
+ Registry.instance.record_offense(callsite_path, location.lineno, key_str, standard_field, logger_class)
51
+ end
49
52
  end
50
53
 
51
- Registry.instance.check_for_removed_offenses(callsite_path, all_fields, logger_class)
54
+ Registry.instance.check_for_removed_offenses(callsite_path, data, logger_class)
52
55
 
53
56
  data
54
57
  end
55
58
 
56
59
  private
57
60
 
61
+ # Skip internal frames (determine_callsite, format_data, format_message, add, info) for performance.
62
+ INTERNAL_FRAMES_TO_SKIP = 5
63
+ MAX_FRAMES_TO_INSPECT = 15
64
+ private_constant :INTERNAL_FRAMES_TO_SKIP, :MAX_FRAMES_TO_INSPECT
65
+
58
66
  def determine_callsite
59
- locations = caller_locations(1, 30) || []
67
+ locations = caller_locations(INTERNAL_FRAMES_TO_SKIP, MAX_FRAMES_TO_INSPECT) || []
68
+ locations = caller_locations(1, MAX_FRAMES_TO_INSPECT) || [] if locations.empty?
60
69
 
61
70
  locations.find do |loc|
62
71
  path = loc.path
@@ -77,12 +86,6 @@ module Labkit
77
86
  start_idx += 1 if absolute_path[start_idx] == '/'
78
87
  absolute_path[start_idx..]
79
88
  end
80
-
81
- def extract_string_keys(data)
82
- return Set.new unless data.is_a?(Hash)
83
-
84
- data.keys.to_set(&:to_s)
85
- end
86
89
  end
87
90
  end
88
91
  end
@@ -109,6 +109,12 @@ module Labkit
109
109
  config = Config.load
110
110
  config.fetch('offenses', [])
111
111
  end
112
+
113
+ def extract_string_keys(data)
114
+ return Set.new unless data.is_a?(Hash)
115
+
116
+ data.keys.to_set(&:to_s)
117
+ end
112
118
  end
113
119
  end
114
120
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-labkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newdigate