gitlab-labkit 1.3.2 → 1.3.4

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: 8d8908ac363f634bae5e4a138d34f9d9e83f44297d17ff370bacb0e573c88ceb
4
- data.tar.gz: b9527b0b05d8b828a4b3bf890b35af60d9ae6e4e893e98558577d419f9bddb5a
3
+ metadata.gz: a29bc2351fbe292697c582547316e370a7320826be10ecb9ef26580b1d5d3dce
4
+ data.tar.gz: f489a1fdd02e6a8ba3750c93bcab4baaa4907983abcaf81544e3ec300234a88e
5
5
  SHA512:
6
- metadata.gz: d658010fd0809876abf220bcdb5b401a19cde96a9ce25006ddf83efac22a6cc7b80bb633b0aa60becb3874138b88da5697898ba77f0b5a7edb199013392dfff5
7
- data.tar.gz: c35a260846129ae94108189da9c844753a9937b7a8606ad8db043625cea8cf409a62483a1a80510c7b6fc3080de70afc87af888b9285cabef520c0d115f54fda
6
+ metadata.gz: f5b4397587a97aa9aadb2b8b4606c675337110ab65d410f211d0c33a0e89fc6b4c2b68f8d07d78906ccd680e31612439d4b316ba955b770a7074582d6b7f80e4
7
+ data.tar.gz: 521c43e11ede3e207218574c00b5644f2907deb19d876213c862818c0e3c12ff65f1eaeaa4c6b9b1afeb0a59f9d20a67552c7a8a7d8dbb48997d9cc7d55d30ac
data/.copier-answers.yml CHANGED
@@ -3,7 +3,7 @@
3
3
  # See the project for instructions on how to update the project
4
4
  #
5
5
  # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
6
- _commit: v1.38.0
6
+ _commit: v1.39.0
7
7
  _src_path: https://gitlab.com/gitlab-com/gl-infra/common-template-copier.git
8
8
  ee_licensed: false
9
9
  golang: false
@@ -18,6 +18,7 @@ module Labkit
18
18
  class << self
19
19
  def register_wrapper_pattern(pattern)
20
20
  wrapper_patterns << pattern
21
+ @combined_ignore_pattern = nil
21
22
  end
22
23
 
23
24
  def wrapper_patterns
@@ -26,6 +27,11 @@ module Labkit
26
27
 
27
28
  def reset_wrapper_patterns!
28
29
  @wrapper_patterns = nil
30
+ @combined_ignore_pattern = nil
31
+ end
32
+
33
+ def combined_ignore_pattern
34
+ @combined_ignore_pattern ||= Regexp.union(IGNORE_PATHS + wrapper_patterns)
29
35
  end
30
36
  end
31
37
 
@@ -38,17 +44,20 @@ module Labkit
38
44
  callsite_path = normalize_path(location.path)
39
45
  return data unless callsite_path
40
46
 
41
- all_fields = extract_string_keys(data)
42
47
  logger_class = self.class.name || 'AnonymousLogger'
43
48
 
44
- all_fields.each do |field|
45
- standard_field = Labkit::Fields::Deprecated.standard_field_for(field)
46
- next unless standard_field
49
+ deprecated_lookup = Labkit::Fields::Deprecated.all
50
+ if data.is_a?(Hash)
51
+ data.each_key do |key|
52
+ key_str = key.to_s
53
+ standard_field = deprecated_lookup[key_str]
54
+ next unless standard_field
47
55
 
48
- Registry.instance.record_offense(callsite_path, location.lineno, field, standard_field, logger_class)
56
+ Registry.instance.record_offense(callsite_path, location.lineno, key_str, standard_field, logger_class)
57
+ end
49
58
  end
50
59
 
51
- Registry.instance.check_for_removed_offenses(callsite_path, all_fields, logger_class)
60
+ Registry.instance.check_for_removed_offenses(callsite_path, data, logger_class)
52
61
 
53
62
  data
54
63
  end
@@ -63,13 +72,13 @@ module Labkit
63
72
  def determine_callsite
64
73
  locations = caller_locations(INTERNAL_FRAMES_TO_SKIP, MAX_FRAMES_TO_INSPECT) || []
65
74
  locations = caller_locations(1, MAX_FRAMES_TO_INSPECT) || [] if locations.empty?
75
+ ignore_pattern = LogInterceptor.combined_ignore_pattern
66
76
 
67
77
  locations.find do |loc|
68
78
  path = loc.path
69
79
 
70
80
  next if path == __FILE__
71
- next if IGNORE_PATHS.any? { |pattern| pattern.match?(path) }
72
- next if LogInterceptor.wrapper_patterns.any? { |pattern| pattern.match?(path) }
81
+ next if ignore_pattern.match?(path)
73
82
 
74
83
  true
75
84
  end
@@ -83,12 +92,6 @@ module Labkit
83
92
  start_idx += 1 if absolute_path[start_idx] == '/'
84
93
  absolute_path[start_idx..]
85
94
  end
86
-
87
- def extract_string_keys(data)
88
- return Set.new unless data.is_a?(Hash)
89
-
90
- data.keys.to_set(&:to_s)
91
- end
92
95
  end
93
96
  end
94
97
  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.2
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newdigate