umbrellio-utils 1.10.2 → 1.11.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/umbrellio_utils/rubocop/cop/custom/regex_rules.rb +55 -0
- data/lib/umbrellio_utils/rubocop.rb +3 -0
- data/lib/umbrellio_utils/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9165c91dbb79ad43e8cc63d58789550589b944273762b32a813f07ed7efab1e7
|
|
4
|
+
data.tar.gz: 28e172b27fb9d9bedae987ba17e58767985b4860322e1b07c3824b53de4822e4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a834763488ba0b1573dcdd1d927ff1997fa9a45021d71501b053243a33d7a6344e4d42a1dd286238fbd36d7be49532a960842f2e3d33a8d687cf344ca80b6a48
|
|
7
|
+
data.tar.gz: 998d29af9ea53290721abbe8f675c1084722450731da4e0f3e0faa9960deb51b30dde2678eca2aa02067527b8f47ea280188fefa0b778e39a2764fb3c5d76583
|
data/Gemfile.lock
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Custom
|
|
6
|
+
class RegexRules < Base
|
|
7
|
+
def on_new_investigation
|
|
8
|
+
return if processed_source.blank?
|
|
9
|
+
|
|
10
|
+
rules.each do |rule|
|
|
11
|
+
next unless applies_to_file?(rule)
|
|
12
|
+
|
|
13
|
+
regex = Regexp.new(rule["regex"])
|
|
14
|
+
processed_source.raw_source.each_line.with_index(1) do |line, lineno|
|
|
15
|
+
next unless (match = regex.match(line))
|
|
16
|
+
|
|
17
|
+
range = range_for_match(lineno, match)
|
|
18
|
+
add_offense(range, message: rule["message"])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def rules
|
|
26
|
+
cop_config["Rules"] || []
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def applies_to_file?(rule)
|
|
30
|
+
path = processed_source.path.sub("#{Dir.pwd}/", "") # relative path
|
|
31
|
+
|
|
32
|
+
# Check exclusions first
|
|
33
|
+
if rule["exclude_paths"]&.any? do |pattern|
|
|
34
|
+
File.fnmatch?(pattern, path)
|
|
35
|
+
end
|
|
36
|
+
return false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Then check inclusions
|
|
40
|
+
return true unless rule["paths"] # no restriction
|
|
41
|
+
|
|
42
|
+
rule["paths"].any? { |pattern| File.fnmatch?(pattern, path, File::FNM_PATHNAME) }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def range_for_match(lineno, match)
|
|
46
|
+
buffer = processed_source.buffer
|
|
47
|
+
line_range = buffer.line_range(lineno)
|
|
48
|
+
start_pos = line_range.begin_pos + match.begin(0)
|
|
49
|
+
end_pos = line_range.begin_pos + match.end(0)
|
|
50
|
+
Parser::Source::Range.new(buffer, start_pos, end_pos)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: umbrellio-utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Team Umbrellio
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: memery
|
|
@@ -64,6 +64,8 @@ files:
|
|
|
64
64
|
- lib/umbrellio_utils/random.rb
|
|
65
65
|
- lib/umbrellio_utils/request_wrapper.rb
|
|
66
66
|
- lib/umbrellio_utils/rounding.rb
|
|
67
|
+
- lib/umbrellio_utils/rubocop.rb
|
|
68
|
+
- lib/umbrellio_utils/rubocop/cop/custom/regex_rules.rb
|
|
67
69
|
- lib/umbrellio_utils/semantic_logger/tiny_json_formatter.rb
|
|
68
70
|
- lib/umbrellio_utils/sql.rb
|
|
69
71
|
- lib/umbrellio_utils/store.rb
|