goodcheck 2.5.2 → 2.6.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -3
  3. data/lib/goodcheck.rb +3 -1
  4. data/lib/goodcheck/cli.rb +78 -54
  5. data/lib/goodcheck/commands/check.rb +19 -1
  6. data/lib/goodcheck/commands/config_loading.rb +19 -2
  7. data/lib/goodcheck/commands/init.rb +4 -2
  8. data/lib/goodcheck/commands/pattern.rb +2 -1
  9. data/lib/goodcheck/commands/test.rb +5 -4
  10. data/lib/goodcheck/config_loader.rb +5 -4
  11. data/lib/goodcheck/error.rb +3 -0
  12. data/lib/goodcheck/exit_status.rb +6 -0
  13. data/lib/goodcheck/glob.rb +14 -3
  14. data/lib/goodcheck/import_loader.rb +25 -9
  15. data/lib/goodcheck/version.rb +1 -1
  16. metadata +5 -55
  17. data/.github/dependabot.yml +0 -18
  18. data/.github/workflows/release.yml +0 -16
  19. data/.github/workflows/test.yml +0 -46
  20. data/.gitignore +0 -13
  21. data/.rubocop.yml +0 -5
  22. data/Dockerfile +0 -13
  23. data/Gemfile +0 -6
  24. data/Rakefile +0 -75
  25. data/bin/console +0 -14
  26. data/bin/setup +0 -8
  27. data/cheatsheet.pdf +0 -0
  28. data/docusaurus/.dockerignore +0 -2
  29. data/docusaurus/.gitignore +0 -12
  30. data/docusaurus/Dockerfile +0 -10
  31. data/docusaurus/docker-compose.yml +0 -18
  32. data/docusaurus/docs/commands.md +0 -69
  33. data/docusaurus/docs/configuration.md +0 -300
  34. data/docusaurus/docs/development.md +0 -15
  35. data/docusaurus/docs/getstarted.md +0 -46
  36. data/docusaurus/docs/rules.md +0 -79
  37. data/docusaurus/website/README.md +0 -193
  38. data/docusaurus/website/core/Footer.js +0 -100
  39. data/docusaurus/website/package.json +0 -14
  40. data/docusaurus/website/pages/en/index.js +0 -207
  41. data/docusaurus/website/pages/en/versions.js +0 -118
  42. data/docusaurus/website/sidebars.json +0 -11
  43. data/docusaurus/website/siteConfig.js +0 -171
  44. data/docusaurus/website/static/css/code-block-buttons.css +0 -39
  45. data/docusaurus/website/static/css/custom.css +0 -245
  46. data/docusaurus/website/static/img/favicon.ico +0 -0
  47. data/docusaurus/website/static/js/code-block-buttons.js +0 -47
  48. data/docusaurus/website/versioned_docs/version-1.0.0/commands.md +0 -70
  49. data/docusaurus/website/versioned_docs/version-1.0.0/configuration.md +0 -296
  50. data/docusaurus/website/versioned_docs/version-1.0.0/development.md +0 -16
  51. data/docusaurus/website/versioned_docs/version-1.0.0/getstarted.md +0 -47
  52. data/docusaurus/website/versioned_docs/version-1.0.0/rules.md +0 -81
  53. data/docusaurus/website/versioned_docs/version-1.0.2/rules.md +0 -79
  54. data/docusaurus/website/versioned_docs/version-2.4.0/configuration.md +0 -301
  55. data/docusaurus/website/versioned_docs/version-2.4.3/rules.md +0 -80
  56. data/docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
  57. data/docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json +0 -11
  58. data/docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json +0 -11
  59. data/docusaurus/website/versions.json +0 -12
  60. data/docusaurus/website/yarn.lock +0 -6604
  61. data/goodcheck.gemspec +0 -35
  62. data/goodcheck.yml +0 -10
  63. data/logo/GoodCheck Horizontal.pdf +0 -899
  64. data/logo/GoodCheck Horizontal.png +0 -0
  65. data/logo/GoodCheck Horizontal.svg +0 -55
  66. data/logo/GoodCheck logo.png +0 -0
  67. data/logo/GoodCheck vertical.png +0 -0
  68. data/sample.yml +0 -57
@@ -0,0 +1,3 @@
1
+ module Goodcheck
2
+ class Error < StandardError; end
3
+ end
@@ -0,0 +1,6 @@
1
+ module Goodcheck
2
+ module ExitStatus
3
+ EXIT_SUCCESS = 0
4
+ EXIT_ERROR = 1
5
+ end
6
+ end
@@ -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, File::FNM_PATHNAME | File::FNM_EXTGLOB | File::FNM_DOTMATCH)
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 < StandardError
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, "file"
28
- load_file uri, &block
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("Unexpected URI schema: #{uri.class.name}")
44
+ raise UnexpectedSchemaError.new(uri)
33
45
  end
34
46
  end
35
47
 
36
- def load_file(uri)
37
- path = (config_path.parent + uri.path)
38
-
39
- begin
40
- yield path.read
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
 
@@ -1,3 +1,3 @@
1
1
  module Goodcheck
2
- VERSION = "2.5.2"
2
+ VERSION = "2.6.0".freeze
3
3
  end
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.5.2
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-31 00:00:00.000000000 Z
11
+ date: 2020-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -148,56 +148,10 @@ executables:
148
148
  extensions: []
149
149
  extra_rdoc_files: []
150
150
  files:
151
- - ".github/dependabot.yml"
152
- - ".github/workflows/release.yml"
153
- - ".github/workflows/test.yml"
154
- - ".gitignore"
155
- - ".rubocop.yml"
156
151
  - CHANGELOG.md
157
- - Dockerfile
158
- - Gemfile
159
152
  - LICENSE
160
153
  - README.md
161
- - Rakefile
162
- - bin/console
163
- - bin/setup
164
- - cheatsheet.pdf
165
- - docusaurus/.dockerignore
166
- - docusaurus/.gitignore
167
- - docusaurus/Dockerfile
168
- - docusaurus/docker-compose.yml
169
- - docusaurus/docs/commands.md
170
- - docusaurus/docs/configuration.md
171
- - docusaurus/docs/development.md
172
- - docusaurus/docs/getstarted.md
173
- - docusaurus/docs/rules.md
174
- - docusaurus/website/README.md
175
- - docusaurus/website/core/Footer.js
176
- - docusaurus/website/package.json
177
- - docusaurus/website/pages/en/index.js
178
- - docusaurus/website/pages/en/versions.js
179
- - docusaurus/website/sidebars.json
180
- - docusaurus/website/siteConfig.js
181
- - docusaurus/website/static/css/code-block-buttons.css
182
- - docusaurus/website/static/css/custom.css
183
- - docusaurus/website/static/img/favicon.ico
184
- - docusaurus/website/static/js/code-block-buttons.js
185
- - docusaurus/website/versioned_docs/version-1.0.0/commands.md
186
- - docusaurus/website/versioned_docs/version-1.0.0/configuration.md
187
- - docusaurus/website/versioned_docs/version-1.0.0/development.md
188
- - docusaurus/website/versioned_docs/version-1.0.0/getstarted.md
189
- - docusaurus/website/versioned_docs/version-1.0.0/rules.md
190
- - docusaurus/website/versioned_docs/version-1.0.2/rules.md
191
- - docusaurus/website/versioned_docs/version-2.4.0/configuration.md
192
- - docusaurus/website/versioned_docs/version-2.4.3/rules.md
193
- - docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json
194
- - docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json
195
- - docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json
196
- - docusaurus/website/versions.json
197
- - docusaurus/website/yarn.lock
198
154
  - exe/goodcheck
199
- - goodcheck.gemspec
200
- - goodcheck.yml
201
155
  - lib/goodcheck.rb
202
156
  - lib/goodcheck/analyzer.rb
203
157
  - lib/goodcheck/array_helper.rb
@@ -210,6 +164,8 @@ files:
210
164
  - lib/goodcheck/commands/test.rb
211
165
  - lib/goodcheck/config.rb
212
166
  - lib/goodcheck/config_loader.rb
167
+ - lib/goodcheck/error.rb
168
+ - lib/goodcheck/exit_status.rb
213
169
  - lib/goodcheck/glob.rb
214
170
  - lib/goodcheck/home_path.rb
215
171
  - lib/goodcheck/import_loader.rb
@@ -222,12 +178,6 @@ files:
222
178
  - lib/goodcheck/rule.rb
223
179
  - lib/goodcheck/trigger.rb
224
180
  - lib/goodcheck/version.rb
225
- - logo/GoodCheck Horizontal.pdf
226
- - logo/GoodCheck Horizontal.png
227
- - logo/GoodCheck Horizontal.svg
228
- - logo/GoodCheck logo.png
229
- - logo/GoodCheck vertical.png
230
- - sample.yml
231
181
  homepage: https://github.com/sider/goodcheck
232
182
  licenses:
233
183
  - MIT
@@ -247,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
197
  - !ruby/object:Gem::Version
248
198
  version: '0'
249
199
  requirements: []
250
- rubygems_version: 3.1.2
200
+ rubygems_version: 3.1.4
251
201
  signing_key:
252
202
  specification_version: 4
253
203
  summary: Regexp based customizable linter
@@ -1,18 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: bundler
4
- directory: "/"
5
- schedule:
6
- interval: monthly
7
- time: "09:00"
8
- timezone: Asia/Tokyo
9
- open-pull-requests-limit: 10
10
- versioning-strategy: increase
11
- - package-ecosystem: npm
12
- directory: "/docusaurus/website"
13
- schedule:
14
- interval: monthly
15
- time: "09:00"
16
- timezone: Asia/Tokyo
17
- open-pull-requests-limit: 10
18
- versioning-strategy: increase
@@ -1,16 +0,0 @@
1
- name: Release
2
-
3
- on: push
4
-
5
- jobs:
6
- release:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v2
10
- - uses: softprops/action-gh-release@v1
11
- if: startsWith(github.ref, 'refs/tags/')
12
- with:
13
- body: |
14
- See the [changelog](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/CHANGELOG.md) for more details.
15
- env:
16
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -1,46 +0,0 @@
1
- name: Test
2
-
3
- on: [push]
4
-
5
- jobs:
6
- test:
7
- runs-on: ubuntu-latest
8
- strategy:
9
- matrix:
10
- ruby: [2.4, 2.5, 2.6, 2.7]
11
- steps:
12
- - uses: actions/checkout@v2
13
- - uses: ruby/setup-ruby@v1
14
- with:
15
- ruby-version: ${{ matrix.ruby }}
16
- - run: |
17
- gem install bundler --no-document
18
- bundle config set path vendor/bundle
19
- bundle install --jobs=4 --retry=3
20
- - run: bundle exec rake
21
-
22
- build-docs:
23
- runs-on: ubuntu-latest
24
- steps:
25
- - uses: actions/checkout@v2
26
- - uses: ruby/setup-ruby@v1
27
- with:
28
- ruby-version: 2.7
29
- - run: |
30
- gem install bundler --no-document
31
- bundle config set path vendor/bundle
32
- bundle install --jobs=4 --retry=3
33
- - run: bundle exec rake docs:build
34
-
35
- benchmark:
36
- runs-on: ubuntu-latest
37
- steps:
38
- - uses: actions/checkout@v2
39
- - uses: ruby/setup-ruby@v1
40
- with:
41
- ruby-version: 2.7
42
- - run: |
43
- gem install bundler --no-document
44
- bundle config set path vendor/bundle
45
- bundle install --jobs=4 --retry=3
46
- - run: bundle exec rake benchmark:run[10000]
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /vendor/bundle/
3
- /.yardoc
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /.idea
11
- /Gemfile.lock
12
- /.ruby-version
13
- .DS_Store
@@ -1,5 +0,0 @@
1
- # We don't use RuboCop.
2
- # If you really believe a Cop should be enabled, open pull requests for each Cop and explain why it matters.
3
-
4
- AllCops:
5
- DisabledByDefault: true
data/Dockerfile DELETED
@@ -1,13 +0,0 @@
1
- FROM rubylang/ruby:2.6.3-bionic
2
-
3
- ENV DEBIAN_FRONTEND=noninteractive
4
-
5
- RUN mkdir /goodcheck
6
- WORKDIR /goodcheck
7
- COPY . /goodcheck/
8
- RUN rake install
9
-
10
- RUN mkdir /work
11
- WORKDIR /work
12
-
13
- ENTRYPOINT ["goodcheck"]
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in goodcheck.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,75 +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
51
-
52
- namespace :benchmark do
53
- desc "Run benchmark"
54
- task :run, [:n] do |_task, args|
55
- require "benchmark"
56
- require "net/http"
57
- require "tempfile"
58
- require_relative "lib/goodcheck"
59
- require_relative "lib/goodcheck/cli"
60
-
61
- content = Net::HTTP.get(URI("https://raw.githubusercontent.com/ruby/ruby/0256e4f0f5e10f0a15cbba2cd64e252dfa864e4a/gc.c"))
62
- target_file = Tempfile.new("goodcheck-benchmark-")
63
- target_file.write content
64
- target_file = target_file.path
65
-
66
- n = Integer(args[:n] || 1000)
67
- puts "n = #{n}"
68
-
69
- Benchmark.bm do |x|
70
- x.report do
71
- n.times { Goodcheck::CLI.new(stdout: STDOUT, stderr: STDERR).run(["check", target_file]) }
72
- end
73
- end
74
- end
75
- end
@@ -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
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here