goodcheck 2.4.4 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -2
- data/README.md +107 -50
- data/lib/goodcheck.rb +4 -3
- 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 +6 -5
- 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 -8
- data/docusaurus/website/yarn.lock +0 -6844
- 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
@@ -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.0
|
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-18 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
data/docusaurus/.gitignore
DELETED
data/docusaurus/Dockerfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
version: "3"
|
2
|
-
|
3
|
-
services:
|
4
|
-
docusaurus:
|
5
|
-
build: .
|
6
|
-
ports:
|
7
|
-
- 3000:3000
|
8
|
-
- 35729:35729
|
9
|
-
volumes:
|
10
|
-
- ./docs:/app/docs
|
11
|
-
- ./website/blog:/app/website/blog
|
12
|
-
- ./website/core:/app/website/core
|
13
|
-
- ./website/i18n:/app/website/i18n
|
14
|
-
- ./website/pages:/app/website/pages
|
15
|
-
- ./website/static:/app/website/static
|
16
|
-
- ./website/sidebars.json:/app/website/sidebars.json
|
17
|
-
- ./website/siteConfig.js:/app/website/siteConfig.js
|
18
|
-
working_dir: /app/website
|
data/docusaurus/docs/commands.md
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
---
|
2
|
-
id: commands
|
3
|
-
title: Commands
|
4
|
-
sidebar_label: Commands
|
5
|
-
---
|
6
|
-
|
7
|
-
|
8
|
-
## `goodcheck init [options]`
|
9
|
-
|
10
|
-
The `init` command generates an example of a configuration file.
|
11
|
-
|
12
|
-
Available options are:
|
13
|
-
|
14
|
-
* `-c=[CONFIG]`, `--config=[CONFIG]` to specify the configuration file name to generate.
|
15
|
-
* `--force` to allow overwriting of an existing config file.
|
16
|
-
|
17
|
-
## `goodcheck check [options] targets...`
|
18
|
-
|
19
|
-
The `check` command checks your programs under `targets...`.
|
20
|
-
You can pass:
|
21
|
-
|
22
|
-
* Directory paths, or
|
23
|
-
* Paths to files.
|
24
|
-
|
25
|
-
When you omit `targets`, it checks all files in `.`.
|
26
|
-
|
27
|
-
Available options are:
|
28
|
-
|
29
|
-
* `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
|
30
|
-
* `-R [rule]`, `--rule=[rule]` to specify the rules you want to check.
|
31
|
-
* `--format=[text|json]` to specify output format.
|
32
|
-
* `-v`, `--verbose` to be verbose.
|
33
|
-
* `--debug` to print all debug messages.
|
34
|
-
* `--force` to ignore downloaded caches.
|
35
|
-
|
36
|
-
`goodcheck check` exits with:
|
37
|
-
|
38
|
-
* `0` when it does not find any matching text fragment.
|
39
|
-
* `2` when it finds some matching text.
|
40
|
-
* `1` when it finds some error.
|
41
|
-
|
42
|
-
You can check its exit status to identify if the tool finds some pattern or not.
|
43
|
-
|
44
|
-
## `goodcheck test [options]`
|
45
|
-
|
46
|
-
The `test` command tests rules.
|
47
|
-
The test contains:
|
48
|
-
|
49
|
-
* Validation of rule `id` uniqueness.
|
50
|
-
* If `pass` examples does not match with any of `pattern`s.
|
51
|
-
* If `fail` examples matches with some of `pattern`s.
|
52
|
-
|
53
|
-
Use `test` command when you add a new rule to be sure you are writing rules correctly.
|
54
|
-
|
55
|
-
Available options are:
|
56
|
-
|
57
|
-
* `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
|
58
|
-
* `-v`, `--verbose` to be verbose.
|
59
|
-
* `--debug` to print all debug messages.
|
60
|
-
* `--force` to ignore downloaded caches
|
61
|
-
|
62
|
-
## `goodcheck pattern [options] ids...`
|
63
|
-
|
64
|
-
The `pattern` command prints the regular expressions generated from the patterns.
|
65
|
-
The command is for debugging patterns, especially token patterns.
|
66
|
-
|
67
|
-
The available option is:
|
68
|
-
|
69
|
-
* `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
|