goodcheck 2.4.3 → 2.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +3 -3
- data/CHANGELOG.md +5 -0
- data/README.md +4 -2
- data/Rakefile +16 -2
- data/docusaurus/website/package.json +1 -1
- data/docusaurus/website/versioned_docs/version-2.4.3/rules.md +80 -0
- data/docusaurus/website/versions.json +2 -0
- data/docusaurus/website/yarn.lock +309 -205
- data/goodcheck.gemspec +4 -3
- data/goodcheck.yml +10 -0
- data/lib/goodcheck/buffer.rb +1 -0
- data/lib/goodcheck/cli.rb +6 -2
- data/lib/goodcheck/commands/check.rb +8 -7
- data/lib/goodcheck/commands/config_loading.rb +1 -1
- data/lib/goodcheck/commands/test.rb +32 -4
- data/lib/goodcheck/config_loader.rb +1 -1
- data/lib/goodcheck/glob.rb +1 -1
- data/lib/goodcheck/issue.rb +1 -0
- data/lib/goodcheck/trigger.rb +2 -0
- data/lib/goodcheck/version.rb +1 -1
- metadata +39 -11
data/goodcheck.gemspec
CHANGED
@@ -24,12 +24,13 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.required_ruby_version = '>= 2.4.0'
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", ">= 1.16"
|
27
|
-
spec.add_development_dependency "rake", "~>
|
27
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
28
28
|
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
-
spec.add_development_dependency "minitest-reporters", "~> 1.
|
29
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.4.2"
|
30
30
|
|
31
31
|
spec.add_runtime_dependency "activesupport", ">= 4.0", "< 7.0"
|
32
|
-
spec.add_runtime_dependency "strong_json", "
|
32
|
+
spec.add_runtime_dependency "strong_json", ">= 1.1", "< 2.2"
|
33
33
|
spec.add_runtime_dependency "rainbow", "~> 3.0.0"
|
34
34
|
spec.add_runtime_dependency "httpclient", "~> 2.8.3"
|
35
|
+
spec.add_runtime_dependency "psych", ">= 3.1", "< 4.0" # NOTE: Needed for old Ruby versions (<= 2.5)
|
35
36
|
end
|
data/goodcheck.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import:
|
2
|
+
- https://raw.githubusercontent.com/sider/goodcheck-rules/master/rules/typo.yml
|
3
|
+
- https://raw.githubusercontent.com/sider/goodcheck-rules/master/rules/ruby.yml
|
4
|
+
|
5
|
+
exclude:
|
6
|
+
- "**/build"
|
7
|
+
- "**/node_modules"
|
8
|
+
- "**/vendor"
|
9
|
+
- "**/*.{ico,pdf,png}"
|
10
|
+
- "**/yarn.lock"
|
data/lib/goodcheck/buffer.rb
CHANGED
data/lib/goodcheck/cli.rb
CHANGED
@@ -18,7 +18,7 @@ module Goodcheck
|
|
18
18
|
test: "Test your configuration",
|
19
19
|
pattern: "Print regexp for rules",
|
20
20
|
version: "Print version",
|
21
|
-
help: "Show
|
21
|
+
help: "Show help and quit"
|
22
22
|
}
|
23
23
|
|
24
24
|
|
@@ -27,8 +27,12 @@ module Goodcheck
|
|
27
27
|
|
28
28
|
if COMMANDS.key?(command)
|
29
29
|
__send__(command, args)
|
30
|
+
elsif command == :"--version"
|
31
|
+
version(args)
|
30
32
|
else
|
33
|
+
stderr.puts "Invalid command: #{command}" if command
|
31
34
|
help(args)
|
35
|
+
1
|
32
36
|
end
|
33
37
|
rescue => exn
|
34
38
|
stderr.puts exn.inspect
|
@@ -80,7 +84,7 @@ module Goodcheck
|
|
80
84
|
if args.empty?
|
81
85
|
targets << Pathname(".")
|
82
86
|
else
|
83
|
-
|
87
|
+
args.each {|arg| targets << Pathname(arg) }
|
84
88
|
end
|
85
89
|
|
86
90
|
reporter = case format
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Goodcheck
|
2
2
|
module Commands
|
3
3
|
class Check
|
4
|
+
DEFAULT_EXCLUSIONS = [".git", ".svn", ".hg"].freeze
|
5
|
+
|
4
6
|
attr_reader :config_path
|
5
7
|
attr_reader :rules
|
6
8
|
attr_reader :targets
|
@@ -82,24 +84,23 @@ module Goodcheck
|
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
85
|
-
def is_dotfile?(path)
|
86
|
-
/\A\.[^.]+/.match?(path.basename.to_s)
|
87
|
-
end
|
88
|
-
|
89
87
|
def each_file(path, immediate: false, &block)
|
90
88
|
case
|
91
89
|
when path.symlink?
|
92
90
|
# noop
|
93
91
|
when path.directory?
|
94
|
-
|
92
|
+
case
|
93
|
+
when DEFAULT_EXCLUSIONS.include?(path.basename.to_s)
|
94
|
+
# noop
|
95
|
+
when immediate || !excluded?(path)
|
95
96
|
path.children.each do |child|
|
96
97
|
each_file(child, &block)
|
97
98
|
end
|
98
99
|
end
|
99
100
|
when path.file?
|
100
101
|
case
|
101
|
-
when path == config_path
|
102
|
-
# Skip
|
102
|
+
when path == config_path
|
103
|
+
# Skip the config file unless explicitly given by command line
|
103
104
|
yield path if immediate
|
104
105
|
when excluded?(path)
|
105
106
|
# Skip excluded files unless explicitly given by command line
|
@@ -5,7 +5,7 @@ module Goodcheck
|
|
5
5
|
|
6
6
|
def load_config!(force_download:, cache_path:)
|
7
7
|
import_loader = ImportLoader.new(cache_path: cache_path, force_download: force_download, config_path: config_path)
|
8
|
-
content = JSON.parse(JSON.dump(YAML.load(config_path.read, config_path.to_s)), symbolize_names: true)
|
8
|
+
content = JSON.parse(JSON.dump(YAML.load(config_path.read, filename: config_path.to_s)), symbolize_names: true)
|
9
9
|
loader = ConfigLoader.new(path: config_path, content: content, stderr: stderr, import_loader: import_loader)
|
10
10
|
@config = loader.load
|
11
11
|
end
|
@@ -22,6 +22,11 @@ module Goodcheck
|
|
22
22
|
handle_config_errors stderr do
|
23
23
|
load_config!(cache_path: cache_dir_path, force_download: force_download)
|
24
24
|
|
25
|
+
if config.rules.empty?
|
26
|
+
stdout.puts "No rules."
|
27
|
+
return 0
|
28
|
+
end
|
29
|
+
|
25
30
|
validate_rule_uniqueness or return 1
|
26
31
|
validate_rules or return 1
|
27
32
|
|
@@ -44,7 +49,8 @@ module Goodcheck
|
|
44
49
|
stdout.puts " OK!👍"
|
45
50
|
true
|
46
51
|
else
|
47
|
-
|
52
|
+
count = duplicated_ids.size
|
53
|
+
stdout.puts(Rainbow(" Found #{count} #{'duplication'.pluralize(count)}.😞").red)
|
48
54
|
duplicated_ids.each do |id|
|
49
55
|
stdout.puts " #{id}"
|
50
56
|
end
|
@@ -54,10 +60,13 @@ module Goodcheck
|
|
54
60
|
|
55
61
|
def validate_rules
|
56
62
|
test_pass = true
|
63
|
+
success_count = 0
|
64
|
+
failure_count = 0
|
65
|
+
failed_rule_ids = Set[]
|
57
66
|
|
58
67
|
config.rules.each do |rule|
|
59
68
|
if rule.triggers.any? {|trigger| !trigger.passes.empty? || !trigger.fails.empty?}
|
60
|
-
stdout.puts "Testing rule #{rule.id}..."
|
69
|
+
stdout.puts "Testing rule #{Rainbow(rule.id).cyan}..."
|
61
70
|
|
62
71
|
rule_ok = true
|
63
72
|
|
@@ -82,7 +91,8 @@ module Goodcheck
|
|
82
91
|
rule_ok = false
|
83
92
|
|
84
93
|
pass_errors.each do |_, index|
|
85
|
-
stdout.puts " #{(index+1).ordinalize} pass example matched.😱"
|
94
|
+
stdout.puts " #{(index+1).ordinalize} #{Rainbow('pass').green} example matched.😱"
|
95
|
+
failed_rule_ids << rule.id
|
86
96
|
end
|
87
97
|
end
|
88
98
|
|
@@ -91,7 +101,8 @@ module Goodcheck
|
|
91
101
|
rule_ok = false
|
92
102
|
|
93
103
|
fail_errors.each do |_, index|
|
94
|
-
stdout.puts " #{(index+1).ordinalize} fail example didn't match.😱"
|
104
|
+
stdout.puts " #{(index+1).ordinalize} #{Rainbow('fail').red} example didn't match.😱"
|
105
|
+
failed_rule_ids << rule.id
|
95
106
|
end
|
96
107
|
end
|
97
108
|
end
|
@@ -104,10 +115,27 @@ module Goodcheck
|
|
104
115
|
|
105
116
|
if rule_ok
|
106
117
|
stdout.puts " OK!🎉"
|
118
|
+
success_count += 1
|
119
|
+
else
|
120
|
+
failure_count += 1
|
107
121
|
end
|
108
122
|
end
|
109
123
|
end
|
110
124
|
|
125
|
+
unless failed_rule_ids.empty?
|
126
|
+
stdout.puts ""
|
127
|
+
stdout.puts "Failed rules:"
|
128
|
+
failed_rule_ids.each do |rule_id|
|
129
|
+
stdout.puts " - #{Rainbow(rule_id).background(:red)}"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
rule_count = success_count + failure_count
|
134
|
+
stdout.puts ""
|
135
|
+
stdout.puts ["Tested #{rule_count} #{'rule'.pluralize(rule_count)}",
|
136
|
+
Rainbow("#{success_count} #{'success'.pluralize(success_count)}").green,
|
137
|
+
Rainbow("#{failure_count} #{'failure'.pluralize(failure_count)}").red].join(", ")
|
138
|
+
|
111
139
|
test_pass
|
112
140
|
end
|
113
141
|
|
@@ -241,7 +241,7 @@ module Goodcheck
|
|
241
241
|
|
242
242
|
Goodcheck.logger.tagged import do
|
243
243
|
import_loader.load(import) do |content|
|
244
|
-
json = JSON.parse(JSON.dump(YAML.load(content, import)), symbolize_names: true)
|
244
|
+
json = JSON.parse(JSON.dump(YAML.load(content, filename: import)), symbolize_names: true)
|
245
245
|
|
246
246
|
Schema.rules.coerce json
|
247
247
|
load_rules(rules, json)
|
data/lib/goodcheck/glob.rb
CHANGED
data/lib/goodcheck/issue.rb
CHANGED
data/lib/goodcheck/trigger.rb
CHANGED
data/lib/goodcheck/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goodcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.4.2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.4.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,16 +90,22 @@ dependencies:
|
|
90
90
|
name: strong_json
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - "
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.1'
|
96
|
+
- - "<"
|
94
97
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
98
|
+
version: '2.2'
|
96
99
|
type: :runtime
|
97
100
|
prerelease: false
|
98
101
|
version_requirements: !ruby/object:Gem::Requirement
|
99
102
|
requirements:
|
100
|
-
- - "
|
103
|
+
- - ">="
|
101
104
|
- !ruby/object:Gem::Version
|
102
|
-
version: 1.1
|
105
|
+
version: '1.1'
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '2.2'
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
110
|
name: rainbow
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,6 +134,26 @@ dependencies:
|
|
128
134
|
- - "~>"
|
129
135
|
- !ruby/object:Gem::Version
|
130
136
|
version: 2.8.3
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: psych
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '3.1'
|
144
|
+
- - "<"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '4.0'
|
147
|
+
type: :runtime
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '3.1'
|
154
|
+
- - "<"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '4.0'
|
131
157
|
description: Regexp based customizable linter
|
132
158
|
email:
|
133
159
|
- matsumoto@soutaro.com
|
@@ -175,6 +201,7 @@ files:
|
|
175
201
|
- docusaurus/website/versioned_docs/version-1.0.0/rules.md
|
176
202
|
- docusaurus/website/versioned_docs/version-1.0.2/rules.md
|
177
203
|
- docusaurus/website/versioned_docs/version-2.4.0/configuration.md
|
204
|
+
- docusaurus/website/versioned_docs/version-2.4.3/rules.md
|
178
205
|
- docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json
|
179
206
|
- docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json
|
180
207
|
- docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json
|
@@ -182,6 +209,7 @@ files:
|
|
182
209
|
- docusaurus/website/yarn.lock
|
183
210
|
- exe/goodcheck
|
184
211
|
- goodcheck.gemspec
|
212
|
+
- goodcheck.yml
|
185
213
|
- lib/goodcheck.rb
|
186
214
|
- lib/goodcheck/analyzer.rb
|
187
215
|
- lib/goodcheck/array_helper.rb
|
@@ -231,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
259
|
- !ruby/object:Gem::Version
|
232
260
|
version: '0'
|
233
261
|
requirements: []
|
234
|
-
rubygems_version: 3.0.
|
262
|
+
rubygems_version: 3.0.3
|
235
263
|
signing_key:
|
236
264
|
specification_version: 4
|
237
265
|
summary: Regexp based customizable linter
|