goodcheck 2.5.0 → 2.7.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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -2
  3. data/README.md +4 -447
  4. data/lib/goodcheck.rb +5 -5
  5. data/lib/goodcheck/analyzer.rb +13 -9
  6. data/lib/goodcheck/buffer.rb +11 -16
  7. data/lib/goodcheck/cli.rb +80 -56
  8. data/lib/goodcheck/commands/check.rb +42 -26
  9. data/lib/goodcheck/commands/config_loading.rb +20 -2
  10. data/lib/goodcheck/commands/init.rb +4 -2
  11. data/lib/goodcheck/commands/pattern.rb +2 -1
  12. data/lib/goodcheck/commands/test.rb +14 -11
  13. data/lib/goodcheck/config_loader.rb +17 -20
  14. data/lib/goodcheck/error.rb +3 -0
  15. data/lib/goodcheck/exit_status.rb +6 -0
  16. data/lib/goodcheck/glob.rb +14 -3
  17. data/lib/goodcheck/import_loader.rb +42 -10
  18. data/lib/goodcheck/issue.rb +3 -3
  19. data/lib/goodcheck/location.rb +28 -0
  20. data/lib/goodcheck/logger.rb +4 -4
  21. data/lib/goodcheck/reporters/json.rb +4 -0
  22. data/lib/goodcheck/reporters/text.rb +42 -11
  23. data/lib/goodcheck/version.rb +1 -1
  24. metadata +29 -92
  25. data/.github/workflows/test.yml +0 -37
  26. data/.gitignore +0 -13
  27. data/.rubocop.yml +0 -5
  28. data/Dockerfile +0 -13
  29. data/Gemfile +0 -6
  30. data/Rakefile +0 -70
  31. data/benchmark/gc.c +0 -12221
  32. data/bin/console +0 -14
  33. data/bin/setup +0 -8
  34. data/cheatsheet.pdf +0 -0
  35. data/docusaurus/.dockerignore +0 -2
  36. data/docusaurus/.gitignore +0 -12
  37. data/docusaurus/Dockerfile +0 -10
  38. data/docusaurus/docker-compose.yml +0 -18
  39. data/docusaurus/docs/commands.md +0 -69
  40. data/docusaurus/docs/configuration.md +0 -300
  41. data/docusaurus/docs/development.md +0 -15
  42. data/docusaurus/docs/getstarted.md +0 -46
  43. data/docusaurus/docs/rules.md +0 -79
  44. data/docusaurus/website/README.md +0 -193
  45. data/docusaurus/website/core/Footer.js +0 -100
  46. data/docusaurus/website/package.json +0 -14
  47. data/docusaurus/website/pages/en/index.js +0 -207
  48. data/docusaurus/website/pages/en/versions.js +0 -118
  49. data/docusaurus/website/sidebars.json +0 -11
  50. data/docusaurus/website/siteConfig.js +0 -171
  51. data/docusaurus/website/static/css/code-block-buttons.css +0 -39
  52. data/docusaurus/website/static/css/custom.css +0 -245
  53. data/docusaurus/website/static/img/favicon.ico +0 -0
  54. data/docusaurus/website/static/js/code-block-buttons.js +0 -47
  55. data/docusaurus/website/versioned_docs/version-1.0.0/commands.md +0 -70
  56. data/docusaurus/website/versioned_docs/version-1.0.0/configuration.md +0 -296
  57. data/docusaurus/website/versioned_docs/version-1.0.0/development.md +0 -16
  58. data/docusaurus/website/versioned_docs/version-1.0.0/getstarted.md +0 -47
  59. data/docusaurus/website/versioned_docs/version-1.0.0/rules.md +0 -81
  60. data/docusaurus/website/versioned_docs/version-1.0.2/rules.md +0 -79
  61. data/docusaurus/website/versioned_docs/version-2.4.0/configuration.md +0 -301
  62. data/docusaurus/website/versioned_docs/version-2.4.3/rules.md +0 -80
  63. data/docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
  64. data/docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json +0 -11
  65. data/docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json +0 -11
  66. data/docusaurus/website/versions.json +0 -10
  67. data/docusaurus/website/yarn.lock +0 -6806
  68. data/goodcheck.gemspec +0 -36
  69. data/goodcheck.yml +0 -10
  70. data/logo/GoodCheck Horizontal.pdf +0 -899
  71. data/logo/GoodCheck Horizontal.png +0 -0
  72. data/logo/GoodCheck Horizontal.svg +0 -55
  73. data/logo/GoodCheck logo.png +0 -0
  74. data/logo/GoodCheck vertical.png +0 -0
  75. data/sample.yml +0 -57
@@ -44,6 +44,10 @@ module Goodcheck
44
44
  def issue(issue)
45
45
  issues << issue
46
46
  end
47
+
48
+ def summary
49
+ # noop
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -5,6 +5,8 @@ module Goodcheck
5
5
 
6
6
  def initialize(stdout:)
7
7
  @stdout = stdout
8
+ @file_count = 0
9
+ @issue_count = 0
8
10
  end
9
11
 
10
12
  def analysis
@@ -12,6 +14,7 @@ module Goodcheck
12
14
  end
13
15
 
14
16
  def file(path)
17
+ @file_count += 1
15
18
  yield
16
19
  end
17
20
 
@@ -20,21 +23,49 @@ module Goodcheck
20
23
  end
21
24
 
22
25
  def issue(issue)
26
+ @issue_count += 1
27
+
28
+ message = issue.rule.message.lines.first.chomp
29
+
23
30
  if issue.location
24
- line = issue.buffer.line(issue.location.start_line)
25
- end_column = if issue.location.start_line == issue.location.end_line
26
- issue.location.end_column
27
- else
28
- line.bytesize
29
- end
30
- colored_line = line.byteslice(0, issue.location.start_column) + Rainbow(line.byteslice(issue.location.start_column, end_column - issue.location.start_column)).red + line.byteslice(end_column, line.bytesize)
31
- stdout.puts "#{issue.path}:#{issue.location.start_line}:#{colored_line.chomp}:\t#{issue.rule.message.lines.first.chomp}"
31
+ start_line = issue.location.start_line
32
+ start_column = issue.location.start_column
33
+ start_column_index = start_column - 1
34
+ line = issue.buffer.line(start_line)
35
+ column_size = if issue.location.one_line?
36
+ issue.location.column_size
37
+ else
38
+ line.bytesize - start_column
39
+ end
40
+ stdout.puts "#{Rainbow(issue.path).cyan}:#{start_line}:#{start_column}: #{message}"
41
+ stdout.puts line.chomp
42
+ stdout.puts (" " * start_column_index) + Rainbow("^" + "~" * (column_size - 1)).yellow
32
43
  else
33
- line = issue.buffer.line(1)&.chomp
34
- line = line ? Rainbow(line).red : '-'
35
- stdout.puts "#{issue.path}:-:#{line}:\t#{issue.rule.message.lines.first.chomp}"
44
+ stdout.puts "#{Rainbow(issue.path).cyan}:-:-: #{message}"
36
45
  end
37
46
  end
47
+
48
+ def summary
49
+ files = case @file_count
50
+ when 0
51
+ "no files"
52
+ when 1
53
+ "1 file"
54
+ else
55
+ "#{@file_count} files"
56
+ end
57
+ issues = case @issue_count
58
+ when 0
59
+ Rainbow("no issues").green
60
+ when 1
61
+ Rainbow("1 issue").red
62
+ else
63
+ Rainbow("#{@issue_count} issues").red
64
+ end
65
+
66
+ stdout.puts ""
67
+ stdout.puts "#{files} inspected, #{issues} detected"
68
+ end
38
69
  end
39
70
  end
40
71
  end
@@ -1,3 +1,3 @@
1
1
  module Goodcheck
2
- VERSION = "2.5.0"
2
+ VERSION = "2.7.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.0
4
+ version: 2.7.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: 2020-02-27 00:00:00.000000000 Z
11
+ date: 2020-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,64 +28,58 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
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
40
  version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '5.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest-reporters
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.4.2
61
+ version: '1.4'
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.4.2
68
+ version: '1.4'
69
69
  - !ruby/object:Gem::Dependency
70
- name: activesupport
70
+ name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '4.0'
76
- - - "<"
77
- - !ruby/object:Gem::Version
78
- version: '7.0'
79
- type: :runtime
75
+ version: '0.18'
76
+ type: :development
80
77
  prerelease: false
81
78
  version_requirements: !ruby/object:Gem::Requirement
82
79
  requirements:
83
80
  - - ">="
84
81
  - !ruby/object:Gem::Version
85
- version: '4.0'
86
- - - "<"
87
- - !ruby/object:Gem::Version
88
- version: '7.0'
82
+ version: '0.18'
89
83
  - !ruby/object:Gem::Dependency
90
84
  name: strong_json
91
85
  requirement: !ruby/object:Gem::Requirement
@@ -110,30 +104,22 @@ dependencies:
110
104
  name: rainbow
111
105
  requirement: !ruby/object:Gem::Requirement
112
106
  requirements:
113
- - - "~>"
114
- - !ruby/object:Gem::Version
115
- version: 3.0.0
116
- type: :runtime
117
- prerelease: false
118
- version_requirements: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - "~>"
107
+ - - ">="
121
108
  - !ruby/object:Gem::Version
122
- version: 3.0.0
123
- - !ruby/object:Gem::Dependency
124
- name: httpclient
125
- requirement: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
109
+ version: '3.0'
110
+ - - "<"
128
111
  - !ruby/object:Gem::Version
129
- version: 2.8.3
112
+ version: '4.0'
130
113
  type: :runtime
131
114
  prerelease: false
132
115
  version_requirements: !ruby/object:Gem::Requirement
133
116
  requirements:
134
- - - "~>"
117
+ - - ">="
135
118
  - !ruby/object:Gem::Version
136
- version: 2.8.3
119
+ version: '3.0'
120
+ - - "<"
121
+ - !ruby/object:Gem::Version
122
+ version: '4.0'
137
123
  - !ruby/object:Gem::Dependency
138
124
  name: psych
139
125
  requirement: !ruby/object:Gem::Requirement
@@ -162,55 +148,10 @@ executables:
162
148
  extensions: []
163
149
  extra_rdoc_files: []
164
150
  files:
165
- - ".github/workflows/test.yml"
166
- - ".gitignore"
167
- - ".rubocop.yml"
168
151
  - CHANGELOG.md
169
- - Dockerfile
170
- - Gemfile
171
152
  - LICENSE
172
153
  - README.md
173
- - Rakefile
174
- - benchmark/gc.c
175
- - bin/console
176
- - bin/setup
177
- - cheatsheet.pdf
178
- - docusaurus/.dockerignore
179
- - docusaurus/.gitignore
180
- - docusaurus/Dockerfile
181
- - docusaurus/docker-compose.yml
182
- - docusaurus/docs/commands.md
183
- - docusaurus/docs/configuration.md
184
- - docusaurus/docs/development.md
185
- - docusaurus/docs/getstarted.md
186
- - docusaurus/docs/rules.md
187
- - docusaurus/website/README.md
188
- - docusaurus/website/core/Footer.js
189
- - docusaurus/website/package.json
190
- - docusaurus/website/pages/en/index.js
191
- - docusaurus/website/pages/en/versions.js
192
- - docusaurus/website/sidebars.json
193
- - docusaurus/website/siteConfig.js
194
- - docusaurus/website/static/css/code-block-buttons.css
195
- - docusaurus/website/static/css/custom.css
196
- - docusaurus/website/static/img/favicon.ico
197
- - docusaurus/website/static/js/code-block-buttons.js
198
- - docusaurus/website/versioned_docs/version-1.0.0/commands.md
199
- - docusaurus/website/versioned_docs/version-1.0.0/configuration.md
200
- - docusaurus/website/versioned_docs/version-1.0.0/development.md
201
- - docusaurus/website/versioned_docs/version-1.0.0/getstarted.md
202
- - docusaurus/website/versioned_docs/version-1.0.0/rules.md
203
- - docusaurus/website/versioned_docs/version-1.0.2/rules.md
204
- - docusaurus/website/versioned_docs/version-2.4.0/configuration.md
205
- - docusaurus/website/versioned_docs/version-2.4.3/rules.md
206
- - docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json
207
- - docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json
208
- - docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json
209
- - docusaurus/website/versions.json
210
- - docusaurus/website/yarn.lock
211
154
  - exe/goodcheck
212
- - goodcheck.gemspec
213
- - goodcheck.yml
214
155
  - lib/goodcheck.rb
215
156
  - lib/goodcheck/analyzer.rb
216
157
  - lib/goodcheck/array_helper.rb
@@ -223,6 +164,8 @@ files:
223
164
  - lib/goodcheck/commands/test.rb
224
165
  - lib/goodcheck/config.rb
225
166
  - lib/goodcheck/config_loader.rb
167
+ - lib/goodcheck/error.rb
168
+ - lib/goodcheck/exit_status.rb
226
169
  - lib/goodcheck/glob.rb
227
170
  - lib/goodcheck/home_path.rb
228
171
  - lib/goodcheck/import_loader.rb
@@ -235,17 +178,11 @@ files:
235
178
  - lib/goodcheck/rule.rb
236
179
  - lib/goodcheck/trigger.rb
237
180
  - lib/goodcheck/version.rb
238
- - logo/GoodCheck Horizontal.pdf
239
- - logo/GoodCheck Horizontal.png
240
- - logo/GoodCheck Horizontal.svg
241
- - logo/GoodCheck logo.png
242
- - logo/GoodCheck vertical.png
243
- - sample.yml
244
181
  homepage: https://github.com/sider/goodcheck
245
182
  licenses:
246
183
  - MIT
247
184
  metadata: {}
248
- post_install_message:
185
+ post_install_message:
249
186
  rdoc_options: []
250
187
  require_paths:
251
188
  - lib
@@ -260,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
197
  - !ruby/object:Gem::Version
261
198
  version: '0'
262
199
  requirements: []
263
- rubygems_version: 3.1.2
264
- signing_key:
200
+ rubygems_version: 3.1.4
201
+ signing_key:
265
202
  specification_version: 4
266
203
  summary: Regexp based customizable linter
267
204
  test_files: []
@@ -1,37 +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: eregon/use-ruby-action@master
14
- with:
15
- ruby-version: ${{ matrix.ruby }}
16
- - run: bundle install --jobs=4 --retry=3 --path=vendor/bundle
17
- - run: bundle exec rake
18
-
19
- build-docs:
20
- runs-on: ubuntu-latest
21
- steps:
22
- - uses: actions/checkout@v2
23
- - uses: eregon/use-ruby-action@master
24
- with:
25
- ruby-version: 2.7
26
- - run: bundle install --jobs=4 --retry=3 --path=vendor/bundle
27
- - run: bundle exec rake docs:build
28
-
29
- benchmark:
30
- runs-on: ubuntu-latest
31
- steps:
32
- - uses: actions/checkout@v2
33
- - uses: eregon/use-ruby-action@master
34
- with:
35
- ruby-version: 2.7
36
- - run: bundle install --jobs=4 --retry=3 --path=vendor/bundle
37
- - 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,70 +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_relative "lib/goodcheck"
57
- require_relative "lib/goodcheck/cli"
58
-
59
- target_file = File.join(__dir__, "benchmark", "gc.c")
60
-
61
- n = Integer(args[:n] || 1000)
62
- puts "n = #{n}"
63
-
64
- Benchmark.bm do |x|
65
- x.report do
66
- n.times { Goodcheck::CLI.new(stdout: STDOUT, stderr: STDERR).run(["check", target_file]) }
67
- end
68
- end
69
- end
70
- end