goodcheck 3.0.0 → 3.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +6 -6
- data/lib/goodcheck/buffer.rb +2 -7
- data/lib/goodcheck/import_loader.rb +33 -9
- data/lib/goodcheck/reporters/text.rb +22 -5
- data/lib/goodcheck/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c52f33a7ac472299ab9acdfe418c10f14d7e36c1d709118484ed89bc4c336597
|
4
|
+
data.tar.gz: 9b2021e6127d5f4d5892ac248b04d612ee88d6efb2e0237d54e3e17a25b5ab67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb9085ae8573a2c07a29e7a75f0dd3f3b56340e1cde25ff10fb369c4eb4f1592f3101fc7bcb93a596d2a69fe3b69e0b4e2d35a81cbf65624fa4d471e7853e42e
|
7
|
+
data.tar.gz: 4eb596ffc6d63a26ef61b3b437b363eb517ff4d0923973b484b587ef39026475d927a408f9ab33c29eb72b207f072d844a12135a96dbd3040be9c5f73a8cf2d4
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,23 @@
|
|
2
2
|
|
3
3
|
## HEAD
|
4
4
|
|
5
|
+
## 3.1.0 (2021-07-15)
|
6
|
+
|
7
|
+
* Improve coloring for text format [#208](https://github.com/sider/goodcheck/pull/208)
|
8
|
+
* Output justification with text format [#210](https://github.com/sider/goodcheck/pull/210)
|
9
|
+
|
10
|
+
## 3.0.3 (2021-06-25)
|
11
|
+
|
12
|
+
* Fix HTTP GET retrying [#203](https://github.com/sider/goodcheck/pull/203)
|
13
|
+
|
14
|
+
## 3.0.2 (2021-06-23)
|
15
|
+
|
16
|
+
* Retry importing on Net::OpenTimeout [#202](https://github.com/sider/goodcheck/pull/202)
|
17
|
+
|
18
|
+
## 3.0.1 (2021-06-14)
|
19
|
+
|
20
|
+
* Retry HTTP GET request on importing rules [#197](https://github.com/sider/goodcheck/pull/197)
|
21
|
+
|
5
22
|
## 3.0.0 (2021-06-14)
|
6
23
|
|
7
24
|
Breaking changes:
|
data/README.md
CHANGED
@@ -37,12 +37,12 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
37
37
|
|
38
38
|
To release a new version, follows the steps below:
|
39
39
|
|
40
|
-
1. Update
|
41
|
-
2.
|
42
|
-
3.
|
43
|
-
4.
|
44
|
-
5. Run `bundle exec rake release`, which will create a
|
45
|
-
6.
|
40
|
+
1. Update [`lib/goodcheck/version.rb`](lib/goodcheck/version.rb).
|
41
|
+
2. Update [CHANGELOG.md](CHANGELOG.md).
|
42
|
+
3. Run `bundle exec rake docs:update_version`.
|
43
|
+
4. Run `git add . && git commit -m 'Version <new_version>'`.
|
44
|
+
5. Run `bundle exec rake release`, which will create a tag, push the commit and tag, and publish the gem to [RubyGems.org](https://rubygems.org).
|
45
|
+
6. Run `GIT_USER=<your_nickname> [USE_SSH=true] bundle exec rake docs:publish`.
|
46
46
|
|
47
47
|
## Contributing
|
48
48
|
|
data/lib/goodcheck/buffer.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
module Goodcheck
|
2
2
|
class Buffer
|
3
|
-
attr_reader :path
|
4
|
-
attr_reader :content
|
5
|
-
|
6
3
|
DISABLE_LINE_PATTERNS = [
|
7
4
|
/\/\/ goodcheck-disable-line$/, #JS, Java, C, ...
|
8
5
|
/# goodcheck-disable-line$/, # Ruby, Python, PHP, ...
|
@@ -25,10 +22,8 @@ module Goodcheck
|
|
25
22
|
/' goodcheck-disable-next-line$/, # VB
|
26
23
|
].freeze
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
attr_accessor :DISABLE_NEXT_LINE_PATTERNS
|
31
|
-
end
|
25
|
+
attr_reader :path
|
26
|
+
attr_reader :content
|
32
27
|
|
33
28
|
def initialize(path:, content:)
|
34
29
|
@path = path
|
@@ -18,6 +18,15 @@ module Goodcheck
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
class HTTPGetError < Error
|
22
|
+
attr_reader :response
|
23
|
+
|
24
|
+
def initialize(res)
|
25
|
+
super("HTTP GET #{res.uri} => #{res.code} #{res.message}")
|
26
|
+
@response = res
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
21
30
|
attr_reader :cache_path
|
22
31
|
attr_reader :expires_in
|
23
32
|
attr_reader :force_download
|
@@ -122,15 +131,30 @@ module Goodcheck
|
|
122
131
|
def http_get(uri, limit = 10)
|
123
132
|
raise ArgumentError, "Too many HTTP redirects" if limit == 0
|
124
133
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
res.
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
+
max_retry_count = 2
|
135
|
+
retry_count = 0
|
136
|
+
begin
|
137
|
+
res = Net::HTTP.get_response URI(uri)
|
138
|
+
case res
|
139
|
+
when Net::HTTPSuccess
|
140
|
+
res.body
|
141
|
+
when Net::HTTPRedirection
|
142
|
+
location = res['Location']
|
143
|
+
http_get location, limit - 1
|
144
|
+
when Net::HTTPClientError, Net::HTTPServerError
|
145
|
+
raise HTTPGetError.new(res)
|
146
|
+
else
|
147
|
+
raise Error, "HTTP GET failed due to #{res.inspect}"
|
148
|
+
end
|
149
|
+
rescue Net::OpenTimeout, HTTPGetError => exn
|
150
|
+
if retry_count < max_retry_count
|
151
|
+
retry_count += 1
|
152
|
+
Goodcheck.logger.info "Retry ##{retry_count} - HTTP GET #{uri} due to #{exn.inspect}..."
|
153
|
+
sleep 1
|
154
|
+
retry
|
155
|
+
else
|
156
|
+
raise
|
157
|
+
end
|
134
158
|
end
|
135
159
|
end
|
136
160
|
|
@@ -25,7 +25,16 @@ module Goodcheck
|
|
25
25
|
def issue(issue)
|
26
26
|
@issue_count += 1
|
27
27
|
|
28
|
-
|
28
|
+
format_line = lambda do |line:, column:|
|
29
|
+
format_args = {
|
30
|
+
path: Rainbow(issue.path).cyan,
|
31
|
+
location: Rainbow(":#{line}:#{column}:").dimgray,
|
32
|
+
message: issue.rule.message.lines.first.chomp,
|
33
|
+
rule: Rainbow("(#{issue.rule.id})").dimgray,
|
34
|
+
severity: issue.rule.severity ? Rainbow("[#{issue.rule.severity}]").magenta : ""
|
35
|
+
}
|
36
|
+
format("%<path>s%<location>s %<message>s %<rule>s %<severity>s", format_args).strip
|
37
|
+
end
|
29
38
|
|
30
39
|
if issue.location
|
31
40
|
start_line = issue.location.start_line
|
@@ -37,13 +46,21 @@ module Goodcheck
|
|
37
46
|
else
|
38
47
|
line.bytesize - start_column
|
39
48
|
end
|
40
|
-
|
41
|
-
severity = issue.rule.severity ? Rainbow("[#{issue.rule.severity}]").magenta : ""
|
42
|
-
stdout.puts "#{Rainbow(issue.path).cyan}:#{start_line}:#{start_column}: #{message} #{rule} #{severity}".strip
|
49
|
+
stdout.puts format_line.call(line: start_line, column: start_column)
|
43
50
|
stdout.puts line.chomp
|
44
51
|
stdout.puts (" " * start_column_index) + Rainbow("^" + "~" * (column_size - 1)).yellow
|
45
52
|
else
|
46
|
-
stdout.puts
|
53
|
+
stdout.puts format_line.call(line: "-", column: "-")
|
54
|
+
end
|
55
|
+
|
56
|
+
justifications = issue.rule.justifications
|
57
|
+
unless justifications.empty?
|
58
|
+
stdout.puts ""
|
59
|
+
stdout.puts " #{Rainbow('Justifications').dimgray.underline.italic}:"
|
60
|
+
justifications.each do |justification|
|
61
|
+
stdout.puts " • #{Rainbow(justification).dimgray.italic}"
|
62
|
+
end
|
63
|
+
stdout.puts ""
|
47
64
|
end
|
48
65
|
end
|
49
66
|
|
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: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sider Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
|
-
rubygems_version: 3.2.
|
212
|
+
rubygems_version: 3.2.23
|
213
213
|
signing_key:
|
214
214
|
specification_version: 4
|
215
215
|
summary: Regexp based customizable linter.
|