goodcheck 2.4.5 → 2.6.1
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/CHANGELOG.md +29 -2
- data/README.md +7 -393
- data/lib/goodcheck.rb +4 -2
- data/lib/goodcheck/buffer.rb +44 -1
- data/lib/goodcheck/cli.rb +78 -54
- data/lib/goodcheck/commands/check.rb +20 -1
- data/lib/goodcheck/commands/config_loading.rb +19 -2
- data/lib/goodcheck/commands/init.rb +4 -2
- data/lib/goodcheck/commands/pattern.rb +2 -1
- data/lib/goodcheck/commands/test.rb +5 -4
- data/lib/goodcheck/config_loader.rb +5 -4
- data/lib/goodcheck/error.rb +3 -0
- data/lib/goodcheck/exit_status.rb +6 -0
- data/lib/goodcheck/glob.rb +14 -3
- data/lib/goodcheck/import_loader.rb +42 -10
- data/lib/goodcheck/version.rb +1 -1
- metadata +8 -70
- data/.gitignore +0 -13
- data/.rubocop.yml +0 -5
- data/.travis.yml +0 -11
- data/Dockerfile +0 -13
- data/Gemfile +0 -6
- data/Rakefile +0 -50
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/cheatsheet.pdf +0 -0
- data/docusaurus/.dockerignore +0 -2
- data/docusaurus/.gitignore +0 -12
- data/docusaurus/Dockerfile +0 -10
- data/docusaurus/docker-compose.yml +0 -18
- data/docusaurus/docs/commands.md +0 -69
- data/docusaurus/docs/configuration.md +0 -300
- data/docusaurus/docs/development.md +0 -15
- data/docusaurus/docs/getstarted.md +0 -46
- data/docusaurus/docs/rules.md +0 -79
- data/docusaurus/website/README.md +0 -193
- data/docusaurus/website/core/Footer.js +0 -100
- data/docusaurus/website/package.json +0 -14
- data/docusaurus/website/pages/en/index.js +0 -207
- data/docusaurus/website/pages/en/versions.js +0 -118
- data/docusaurus/website/sidebars.json +0 -11
- data/docusaurus/website/siteConfig.js +0 -171
- data/docusaurus/website/static/css/code-block-buttons.css +0 -39
- data/docusaurus/website/static/css/custom.css +0 -245
- data/docusaurus/website/static/img/favicon.ico +0 -0
- data/docusaurus/website/static/js/code-block-buttons.js +0 -47
- data/docusaurus/website/versioned_docs/version-1.0.0/commands.md +0 -70
- data/docusaurus/website/versioned_docs/version-1.0.0/configuration.md +0 -296
- data/docusaurus/website/versioned_docs/version-1.0.0/development.md +0 -16
- data/docusaurus/website/versioned_docs/version-1.0.0/getstarted.md +0 -47
- data/docusaurus/website/versioned_docs/version-1.0.0/rules.md +0 -81
- data/docusaurus/website/versioned_docs/version-1.0.2/rules.md +0 -79
- data/docusaurus/website/versioned_docs/version-2.4.0/configuration.md +0 -301
- data/docusaurus/website/versioned_docs/version-2.4.3/rules.md +0 -80
- data/docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
- data/docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json +0 -11
- data/docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json +0 -11
- data/docusaurus/website/versions.json +0 -9
- data/docusaurus/website/yarn.lock +0 -6712
- data/goodcheck.gemspec +0 -36
- data/goodcheck.yml +0 -10
- data/logo/GoodCheck Horizontal.pdf +0 -899
- data/logo/GoodCheck Horizontal.png +0 -0
- data/logo/GoodCheck Horizontal.svg +0 -55
- data/logo/GoodCheck logo.png +0 -0
- data/logo/GoodCheck vertical.png +0 -0
- data/sample.yml +0 -57
@@ -2,7 +2,7 @@ module Goodcheck
|
|
2
2
|
class ConfigLoader
|
3
3
|
include ArrayHelper
|
4
4
|
|
5
|
-
class InvalidPattern <
|
5
|
+
class InvalidPattern < Error; end
|
6
6
|
|
7
7
|
Schema = StrongJSON.new do
|
8
8
|
def self.array_or(type)
|
@@ -22,7 +22,8 @@ module Goodcheck
|
|
22
22
|
let :deprecated_token_pattern, object(token: string, case_insensitive: boolean?)
|
23
23
|
|
24
24
|
let :encoding, enum(*Encoding.name_list.map {|name| literal(name) })
|
25
|
-
let :glob_obj, object(pattern: string, encoding: optional(encoding)
|
25
|
+
let :glob_obj, object(pattern: string, encoding: optional(encoding),
|
26
|
+
exclude: enum?(string, array(string)))
|
26
27
|
let :one_glob, enum(glob_obj,
|
27
28
|
string,
|
28
29
|
detector: -> (value) {
|
@@ -344,9 +345,9 @@ module Goodcheck
|
|
344
345
|
globs.map do |glob|
|
345
346
|
case glob
|
346
347
|
when String
|
347
|
-
Glob.new(pattern: glob, encoding: nil)
|
348
|
+
Glob.new(pattern: glob, encoding: nil, exclude: nil)
|
348
349
|
when Hash
|
349
|
-
Glob.new(pattern: glob[:pattern], encoding: glob[:encoding])
|
350
|
+
Glob.new(pattern: glob[:pattern], encoding: glob[:encoding], exclude: glob[:exclude])
|
350
351
|
end
|
351
352
|
end
|
352
353
|
end
|
data/lib/goodcheck/glob.rb
CHANGED
@@ -1,21 +1,32 @@
|
|
1
1
|
module Goodcheck
|
2
2
|
class Glob
|
3
|
+
FNM_FLAGS = File::FNM_PATHNAME | File::FNM_EXTGLOB | File::FNM_DOTMATCH
|
4
|
+
|
3
5
|
attr_reader :pattern
|
4
6
|
attr_reader :encoding
|
7
|
+
attr_reader :exclude
|
5
8
|
|
6
|
-
def initialize(pattern:, encoding:)
|
9
|
+
def initialize(pattern:, encoding:, exclude:)
|
7
10
|
@pattern = pattern
|
8
11
|
@encoding = encoding
|
12
|
+
@exclude = exclude
|
9
13
|
end
|
10
14
|
|
11
15
|
def test(path)
|
12
|
-
path.fnmatch?(pattern,
|
16
|
+
path.fnmatch?(pattern, FNM_FLAGS) && !excluded?(path)
|
13
17
|
end
|
14
18
|
|
15
19
|
def ==(other)
|
16
20
|
other.is_a?(Glob) &&
|
17
21
|
other.pattern == pattern &&
|
18
|
-
other.encoding == encoding
|
22
|
+
other.encoding == encoding &&
|
23
|
+
other.exclude == exclude
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def excluded?(path)
|
29
|
+
Array(exclude).any? { |exc| path.fnmatch?(exc, FNM_FLAGS) }
|
19
30
|
end
|
20
31
|
end
|
21
32
|
end
|
@@ -1,13 +1,23 @@
|
|
1
1
|
module Goodcheck
|
2
2
|
class ImportLoader
|
3
|
-
class UnexpectedSchemaError <
|
3
|
+
class UnexpectedSchemaError < Error
|
4
4
|
attr_reader :uri
|
5
5
|
|
6
6
|
def initialize(uri)
|
7
|
+
super("Unexpected URI schema: #{uri.scheme}")
|
7
8
|
@uri = uri
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
12
|
+
class FileNotFound < Error
|
13
|
+
attr_reader :path
|
14
|
+
|
15
|
+
def initialize(path)
|
16
|
+
super("No such a file: #{path}")
|
17
|
+
@path = path
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
11
21
|
attr_reader :cache_path
|
12
22
|
attr_reader :expires_in
|
13
23
|
attr_reader :force_download
|
@@ -24,20 +34,26 @@ module Goodcheck
|
|
24
34
|
uri = URI.parse(name)
|
25
35
|
|
26
36
|
case uri.scheme
|
27
|
-
when nil
|
28
|
-
load_file
|
37
|
+
when nil
|
38
|
+
load_file name, &block
|
39
|
+
when "file"
|
40
|
+
load_file uri.path, &block
|
29
41
|
when "http", "https"
|
30
42
|
load_http uri, &block
|
31
43
|
else
|
32
|
-
raise UnexpectedSchemaError.new(
|
44
|
+
raise UnexpectedSchemaError.new(uri)
|
33
45
|
end
|
34
46
|
end
|
35
47
|
|
36
|
-
def load_file(
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
48
|
+
def load_file(path)
|
49
|
+
files = Dir.glob(File.join(config_path.parent.to_path, path), File::FNM_DOTMATCH | File::FNM_EXTGLOB).sort
|
50
|
+
if files.empty?
|
51
|
+
raise FileNotFound.new(path)
|
52
|
+
else
|
53
|
+
files.each do |file|
|
54
|
+
Goodcheck.logger.info "Reading file: #{file}"
|
55
|
+
yield File.read(file)
|
56
|
+
end
|
41
57
|
end
|
42
58
|
end
|
43
59
|
|
@@ -71,7 +87,7 @@ module Goodcheck
|
|
71
87
|
if download
|
72
88
|
path.rmtree if path.exist?
|
73
89
|
Goodcheck.logger.info "Downloading content..."
|
74
|
-
content =
|
90
|
+
content = http_get uri
|
75
91
|
Goodcheck.logger.debug "Downloaded content: #{content[0, 1024].inspect}#{content.size > 1024 ? "..." : ""}"
|
76
92
|
yield content
|
77
93
|
write_cache uri, content
|
@@ -85,5 +101,21 @@ module Goodcheck
|
|
85
101
|
path = cache_path + cache_name(uri)
|
86
102
|
path.write(content)
|
87
103
|
end
|
104
|
+
|
105
|
+
# @see https://ruby-doc.org/stdlib-2.7.0/libdoc/net/http/rdoc/Net/HTTP.html#class-Net::HTTP-label-Following+Redirection
|
106
|
+
def http_get(uri, limit = 10)
|
107
|
+
raise ArgumentError, "Too many HTTP redirects" if limit == 0
|
108
|
+
|
109
|
+
res = Net::HTTP.get_response URI(uri)
|
110
|
+
case res
|
111
|
+
when Net::HTTPSuccess
|
112
|
+
res.body
|
113
|
+
when Net::HTTPRedirection
|
114
|
+
location = res['Location']
|
115
|
+
http_get location, limit - 1
|
116
|
+
else
|
117
|
+
raise "Error: HTTP GET #{uri.inspect} #{res.inspect}"
|
118
|
+
end
|
119
|
+
end
|
88
120
|
end
|
89
121
|
end
|
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
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,20 +120,6 @@ dependencies:
|
|
120
120
|
- - "~>"
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: 3.0.0
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
name: httpclient
|
125
|
-
requirement: !ruby/object:Gem::Requirement
|
126
|
-
requirements:
|
127
|
-
- - "~>"
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: 2.8.3
|
130
|
-
type: :runtime
|
131
|
-
prerelease: false
|
132
|
-
version_requirements: !ruby/object:Gem::Requirement
|
133
|
-
requirements:
|
134
|
-
- - "~>"
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: 2.8.3
|
137
123
|
- !ruby/object:Gem::Dependency
|
138
124
|
name: psych
|
139
125
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,54 +148,10 @@ executables:
|
|
162
148
|
extensions: []
|
163
149
|
extra_rdoc_files: []
|
164
150
|
files:
|
165
|
-
- ".gitignore"
|
166
|
-
- ".rubocop.yml"
|
167
|
-
- ".travis.yml"
|
168
151
|
- CHANGELOG.md
|
169
|
-
- Dockerfile
|
170
|
-
- Gemfile
|
171
152
|
- LICENSE
|
172
153
|
- README.md
|
173
|
-
- Rakefile
|
174
|
-
- bin/console
|
175
|
-
- bin/setup
|
176
|
-
- cheatsheet.pdf
|
177
|
-
- docusaurus/.dockerignore
|
178
|
-
- docusaurus/.gitignore
|
179
|
-
- docusaurus/Dockerfile
|
180
|
-
- docusaurus/docker-compose.yml
|
181
|
-
- docusaurus/docs/commands.md
|
182
|
-
- docusaurus/docs/configuration.md
|
183
|
-
- docusaurus/docs/development.md
|
184
|
-
- docusaurus/docs/getstarted.md
|
185
|
-
- docusaurus/docs/rules.md
|
186
|
-
- docusaurus/website/README.md
|
187
|
-
- docusaurus/website/core/Footer.js
|
188
|
-
- docusaurus/website/package.json
|
189
|
-
- docusaurus/website/pages/en/index.js
|
190
|
-
- docusaurus/website/pages/en/versions.js
|
191
|
-
- docusaurus/website/sidebars.json
|
192
|
-
- docusaurus/website/siteConfig.js
|
193
|
-
- docusaurus/website/static/css/code-block-buttons.css
|
194
|
-
- docusaurus/website/static/css/custom.css
|
195
|
-
- docusaurus/website/static/img/favicon.ico
|
196
|
-
- docusaurus/website/static/js/code-block-buttons.js
|
197
|
-
- docusaurus/website/versioned_docs/version-1.0.0/commands.md
|
198
|
-
- docusaurus/website/versioned_docs/version-1.0.0/configuration.md
|
199
|
-
- docusaurus/website/versioned_docs/version-1.0.0/development.md
|
200
|
-
- docusaurus/website/versioned_docs/version-1.0.0/getstarted.md
|
201
|
-
- docusaurus/website/versioned_docs/version-1.0.0/rules.md
|
202
|
-
- docusaurus/website/versioned_docs/version-1.0.2/rules.md
|
203
|
-
- docusaurus/website/versioned_docs/version-2.4.0/configuration.md
|
204
|
-
- docusaurus/website/versioned_docs/version-2.4.3/rules.md
|
205
|
-
- docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json
|
206
|
-
- docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json
|
207
|
-
- docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json
|
208
|
-
- docusaurus/website/versions.json
|
209
|
-
- docusaurus/website/yarn.lock
|
210
154
|
- exe/goodcheck
|
211
|
-
- goodcheck.gemspec
|
212
|
-
- goodcheck.yml
|
213
155
|
- lib/goodcheck.rb
|
214
156
|
- lib/goodcheck/analyzer.rb
|
215
157
|
- lib/goodcheck/array_helper.rb
|
@@ -222,6 +164,8 @@ files:
|
|
222
164
|
- lib/goodcheck/commands/test.rb
|
223
165
|
- lib/goodcheck/config.rb
|
224
166
|
- lib/goodcheck/config_loader.rb
|
167
|
+
- lib/goodcheck/error.rb
|
168
|
+
- lib/goodcheck/exit_status.rb
|
225
169
|
- lib/goodcheck/glob.rb
|
226
170
|
- lib/goodcheck/home_path.rb
|
227
171
|
- lib/goodcheck/import_loader.rb
|
@@ -234,17 +178,11 @@ files:
|
|
234
178
|
- lib/goodcheck/rule.rb
|
235
179
|
- lib/goodcheck/trigger.rb
|
236
180
|
- lib/goodcheck/version.rb
|
237
|
-
- logo/GoodCheck Horizontal.pdf
|
238
|
-
- logo/GoodCheck Horizontal.png
|
239
|
-
- logo/GoodCheck Horizontal.svg
|
240
|
-
- logo/GoodCheck logo.png
|
241
|
-
- logo/GoodCheck vertical.png
|
242
|
-
- sample.yml
|
243
181
|
homepage: https://github.com/sider/goodcheck
|
244
182
|
licenses:
|
245
183
|
- MIT
|
246
184
|
metadata: {}
|
247
|
-
post_install_message:
|
185
|
+
post_install_message:
|
248
186
|
rdoc_options: []
|
249
187
|
require_paths:
|
250
188
|
- lib
|
@@ -259,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
197
|
- !ruby/object:Gem::Version
|
260
198
|
version: '0'
|
261
199
|
requirements: []
|
262
|
-
rubygems_version: 3.
|
263
|
-
signing_key:
|
200
|
+
rubygems_version: 3.1.4
|
201
|
+
signing_key:
|
264
202
|
specification_version: 4
|
265
203
|
summary: Regexp based customizable linter
|
266
204
|
test_files: []
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
data/.travis.yml
DELETED
data/Dockerfile
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rake/testtask"
|
3
|
-
|
4
|
-
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test"
|
6
|
-
t.libs << "lib"
|
7
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
-
end
|
9
|
-
|
10
|
-
task :default => :test
|
11
|
-
|
12
|
-
namespace :docker do
|
13
|
-
task :build do
|
14
|
-
sh 'docker', 'build', '-t', 'sider/goodcheck:dev', '.'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
namespace :docs do
|
19
|
-
desc "Install dependencies for the documentation website"
|
20
|
-
task :install_deps do
|
21
|
-
on_docs_dir do
|
22
|
-
sh "yarn", "install"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
desc "Build the documentation website"
|
27
|
-
task :build => [:install_deps] do
|
28
|
-
on_docs_dir do
|
29
|
-
sh "yarn", "run", "build"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
desc "Update the version of the documentation website"
|
34
|
-
task :update_version => [:install_deps] do
|
35
|
-
on_docs_dir do
|
36
|
-
sh "yarn", "run", "version", Goodcheck::VERSION
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
desc "Publish the documentation website"
|
41
|
-
task :publish => [:build] do
|
42
|
-
on_docs_dir do
|
43
|
-
sh "yarn", "run", "publish-gh-pages"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def on_docs_dir(&block)
|
48
|
-
Dir.chdir "docusaurus/website", &block
|
49
|
-
end
|
50
|
-
end
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "goodcheck"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/cheatsheet.pdf
DELETED
Binary file
|
data/docusaurus/.dockerignore
DELETED