mudguard 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +35 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +6 -1
- data/Gemfile.lock +39 -34
- data/Guardfile +1 -1
- data/lib/mudguard/domain/consts.rb +9 -8
- data/lib/mudguard/domain/dependency.rb +1 -1
- data/lib/mudguard/infrastructure/persistence/project_repository.rb +14 -6
- data/lib/mudguard/infrastructure/rake/task.rb +2 -0
- data/lib/mudguard/version.rb +1 -1
- data/mudguard.gemspec +2 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a871581e7e7227dcc8c20bc00a925eb3b71bd23f76f1e30f76267fe9bbe97503
|
4
|
+
data.tar.gz: 2dec890800cb5661fc6930429d70171c5b29a8e4c888ad6f030d668bb8f0644e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fd2e9ee1f41f0f3d033ba1015a12b715377366876d835003a4b0dd0e5743cd1728d1a6f739812cabb2017b882e2fda33aeec5dde443e79fcfe65f980ff08fda
|
7
|
+
data.tar.gz: 62c6548a4c2b3a3e1bed074be382b3e73b89f60aaa3968217c56d33e4fdc03238a482955697609664055c630c6aa46c634e022f44747123c306ab5f0a5bb31bd
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.5']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
# uses: ruby/setup-ruby@v1
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rspec --format RSpec::Github::Formatter
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -19,7 +19,7 @@ Style/Documentation:
|
|
19
19
|
- 'spec/**/*.rb'
|
20
20
|
|
21
21
|
Style/HashEachMethods:
|
22
|
-
|
22
|
+
Enabled: true
|
23
23
|
|
24
24
|
Style/HashTransformKeys:
|
25
25
|
Enabled: true
|
@@ -30,3 +30,8 @@ Style/HashTransformValues:
|
|
30
30
|
Layout/LineLength:
|
31
31
|
Description: 'Limit lines to 100 characters.'
|
32
32
|
Max: 100
|
33
|
+
|
34
|
+
|
35
|
+
Lint/EmptyFile:
|
36
|
+
Exclude:
|
37
|
+
- 'spec/lib/infrastructure/persistence/project_repository_project/**/*.rb'
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mudguard (0.2.
|
4
|
+
mudguard (0.2.5)
|
5
5
|
parser (~> 2.7)
|
6
6
|
rake (~> 13.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
ast (2.4.
|
11
|
+
ast (2.4.2)
|
12
12
|
byebug (11.1.3)
|
13
|
-
coderay (1.1.
|
14
|
-
diff-lcs (1.
|
15
|
-
ffi (1.
|
13
|
+
coderay (1.1.3)
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
ffi (1.15.0)
|
16
16
|
formatador (0.2.5)
|
17
17
|
guard (2.16.2)
|
18
18
|
formatador (>= 0.2.4)
|
@@ -28,61 +28,65 @@ GEM
|
|
28
28
|
guard (~> 2.1)
|
29
29
|
guard-compat (~> 1.1)
|
30
30
|
rspec (>= 2.99.0, < 4.0)
|
31
|
-
listen (3.
|
31
|
+
listen (3.5.1)
|
32
32
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
33
33
|
rb-inotify (~> 0.9, >= 0.9.10)
|
34
|
-
lumberjack (1.2.
|
34
|
+
lumberjack (1.2.8)
|
35
35
|
method_source (1.0.0)
|
36
36
|
nenv (0.3.0)
|
37
37
|
notiffany (0.1.3)
|
38
38
|
nenv (~> 0.1)
|
39
39
|
shellany (~> 0.0)
|
40
|
-
parallel (1.
|
41
|
-
parser (2.7.
|
42
|
-
ast (~> 2.4.
|
43
|
-
pry (0.
|
40
|
+
parallel (1.20.1)
|
41
|
+
parser (2.7.2.0)
|
42
|
+
ast (~> 2.4.1)
|
43
|
+
pry (0.14.1)
|
44
44
|
coderay (~> 1.1)
|
45
45
|
method_source (~> 1.0)
|
46
|
-
pry-byebug (3.
|
46
|
+
pry-byebug (3.8.0)
|
47
47
|
byebug (~> 11.0)
|
48
|
-
pry (~> 0.
|
48
|
+
pry (~> 0.10)
|
49
49
|
pry-doc (1.1.0)
|
50
50
|
pry (~> 0.11)
|
51
51
|
yard (~> 0.9.11)
|
52
52
|
rainbow (3.0.0)
|
53
|
-
rake (13.0.
|
53
|
+
rake (13.0.3)
|
54
54
|
rb-fsevent (0.10.4)
|
55
55
|
rb-inotify (0.10.1)
|
56
56
|
ffi (~> 1.0)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
rspec-
|
61
|
-
rspec-
|
62
|
-
|
63
|
-
|
64
|
-
|
57
|
+
regexp_parser (2.1.1)
|
58
|
+
rexml (3.2.5)
|
59
|
+
rspec (3.10.0)
|
60
|
+
rspec-core (~> 3.10.0)
|
61
|
+
rspec-expectations (~> 3.10.0)
|
62
|
+
rspec-mocks (~> 3.10.0)
|
63
|
+
rspec-core (3.10.1)
|
64
|
+
rspec-support (~> 3.10.0)
|
65
|
+
rspec-expectations (3.10.1)
|
65
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-
|
67
|
+
rspec-support (~> 3.10.0)
|
68
|
+
rspec-github (2.3.1)
|
69
|
+
rspec-core (~> 3.0)
|
70
|
+
rspec-mocks (3.10.2)
|
68
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
-
rspec-support (~> 3.
|
70
|
-
rspec-support (3.
|
71
|
-
rubocop (0.
|
72
|
+
rspec-support (~> 3.10.0)
|
73
|
+
rspec-support (3.10.2)
|
74
|
+
rubocop (0.93.1)
|
72
75
|
parallel (~> 1.10)
|
73
|
-
parser (>= 2.7.
|
76
|
+
parser (>= 2.7.1.5)
|
74
77
|
rainbow (>= 2.2.2, < 4.0)
|
78
|
+
regexp_parser (>= 1.8)
|
75
79
|
rexml
|
76
|
-
rubocop-ast (>= 0.0
|
80
|
+
rubocop-ast (>= 0.6.0)
|
77
81
|
ruby-progressbar (~> 1.7)
|
78
82
|
unicode-display_width (>= 1.4.0, < 2.0)
|
79
|
-
rubocop-ast (
|
80
|
-
parser (>= 2.7.
|
81
|
-
ruby-progressbar (1.
|
83
|
+
rubocop-ast (1.4.1)
|
84
|
+
parser (>= 2.7.1.5)
|
85
|
+
ruby-progressbar (1.11.0)
|
82
86
|
shellany (0.0.1)
|
83
|
-
thor (1.0
|
87
|
+
thor (1.1.0)
|
84
88
|
unicode-display_width (1.7.0)
|
85
|
-
yard (0.9.
|
89
|
+
yard (0.9.26)
|
86
90
|
|
87
91
|
PLATFORMS
|
88
92
|
ruby
|
@@ -97,6 +101,7 @@ DEPENDENCIES
|
|
97
101
|
pry-doc (~> 1.0)
|
98
102
|
rake (~> 13.0)
|
99
103
|
rspec (~> 3.9)
|
104
|
+
rspec-github
|
100
105
|
rubocop (~> 0.80)
|
101
106
|
|
102
107
|
BUNDLED WITH
|
data/Guardfile
CHANGED
@@ -12,5 +12,5 @@ guard "rspec", rspec_options do
|
|
12
12
|
watch(%r{^lib/mudguard/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
13
13
|
watch(%r{^lib/mudguard/(.+)\.rb$}) { |m| Dir.glob("spec/lib/#{m[1]}_*.rb") }
|
14
14
|
watch("spec/spec_helper.rb") { "spec" }
|
15
|
-
watch(%r{^exe
|
15
|
+
watch(%r{^exe/mudguard$}) { |_| "spec/exe/mudguard_spec.rb" }
|
16
16
|
end
|
@@ -7,14 +7,7 @@ module Mudguard
|
|
7
7
|
# Knows all constants of the project
|
8
8
|
class Consts
|
9
9
|
def initialize(sources:)
|
10
|
-
@consts = sources.flat_map(&:find_consts)
|
11
|
-
.each_with_object({}) do |c, a|
|
12
|
-
path = split_hierarchy(c)
|
13
|
-
const_name = path.last
|
14
|
-
module_names = path.take(path.count - 1)
|
15
|
-
sub_module = module_names.reduce(a) { |h, m| h.key?(m) ? h[m] : h[m] = {} }
|
16
|
-
sub_module[const_name] = {} unless sub_module.key?(const_name)
|
17
|
-
end
|
10
|
+
@consts = sources.flat_map(&:find_consts).each_with_object({}, &method(:add_const))
|
18
11
|
end
|
19
12
|
|
20
13
|
def resolve(module_name, const_name)
|
@@ -34,6 +27,14 @@ module Mudguard
|
|
34
27
|
|
35
28
|
private
|
36
29
|
|
30
|
+
def add_const(const, all_consts)
|
31
|
+
path = split_hierarchy(const)
|
32
|
+
const_name = path.last
|
33
|
+
module_names = path.take(path.count - 1)
|
34
|
+
sub_module = module_names.reduce(all_consts) { |h, m| h.key?(m) ? h[m] : h[m] = {} }
|
35
|
+
sub_module[const_name] = {} unless sub_module.key?(const_name)
|
36
|
+
end
|
37
|
+
|
37
38
|
SEPARATOR = "::"
|
38
39
|
|
39
40
|
def find_const_deeper(current_module, remaining_modules, consts, const_path)
|
@@ -13,16 +13,24 @@ module Mudguard
|
|
13
13
|
def load_source_policies(project_path)
|
14
14
|
file = PolicyFile.read(project_path)
|
15
15
|
scopes = file.flat_map do |patterns, policies|
|
16
|
-
|
17
|
-
sources.flat_map { |s| { source: s, policies: policies } }
|
16
|
+
build_scope(patterns, policies, project_path)
|
18
17
|
end
|
19
18
|
|
20
19
|
sources = scopes.group_by { |e| e[:source] }
|
21
20
|
|
22
|
-
sources.map
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
sources.map(&method(:build_policies))
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def build_policies(source, group)
|
27
|
+
policies = group.flat_map { |r| r[:policies] }.uniq
|
28
|
+
Domain::SourcePolicies.new(source: source, policies: policies)
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_scope(patterns, policies, project_path)
|
32
|
+
sources = RubyFiles.select(project_path, patterns: [patterns])
|
33
|
+
sources.flat_map { |s| { source: s, policies: policies } }
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
data/lib/mudguard/version.rb
CHANGED
data/mudguard.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
spec.metadata["homepage_uri"] = spec.homepage
|
19
19
|
spec.metadata["source_code_uri"] = spec.homepage
|
20
|
+
spec.required_ruby_version = ">= 2.5.3"
|
20
21
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been
|
@@ -37,6 +38,7 @@ Gem::Specification.new do |spec|
|
|
37
38
|
spec.add_development_dependency "pry-doc", "~>1.0"
|
38
39
|
spec.add_development_dependency "rake", "~>13.0"
|
39
40
|
spec.add_development_dependency "rspec", "~> 3.9"
|
41
|
+
spec.add_development_dependency "rspec-github"
|
40
42
|
spec.add_development_dependency "rubocop", "~>0.80"
|
41
43
|
|
42
44
|
spec.add_dependency "parser", "~>2.7"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mudguard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorg Jenni
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01
|
11
|
+
date: 2021-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '3.9'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-github
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rubocop
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,6 +187,7 @@ extensions: []
|
|
173
187
|
extra_rdoc_files: []
|
174
188
|
files:
|
175
189
|
- ".envrc"
|
190
|
+
- ".github/workflows/ruby.yml"
|
176
191
|
- ".gitignore"
|
177
192
|
- ".mudguard.yml"
|
178
193
|
- ".rubocop.yml"
|
@@ -225,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
225
240
|
requirements:
|
226
241
|
- - ">="
|
227
242
|
- !ruby/object:Gem::Version
|
228
|
-
version:
|
243
|
+
version: 2.5.3
|
229
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
245
|
requirements:
|
231
246
|
- - ">="
|