rubocop-rubycw 0.1.0 → 0.1.5
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/.circleci/config.yml +49 -0
- data/LICENSE +21 -0
- data/README.md +16 -6
- data/lib/rubocop-rubycw.rb +1 -0
- data/lib/rubocop/cop/rubycw/rubycw.rb +8 -13
- data/lib/rubocop/rubycw/version.rb +1 -1
- data/lib/rubocop/rubycw/warning_capturer.rb +52 -0
- data/rubocop-rubycw.gemspec +4 -4
- metadata +19 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5c26092534075459ba32b265307ae0e5091bb00dbd2edb7f3b9f56b4a067c23
|
4
|
+
data.tar.gz: 9773c0b1104531124f98ade8adb90085f862400efe1d9249a35ac6e6667c5b4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9e03d4a522a88600d43b9688eaf013bce5ae1f654c36232210366022ae6e47dd87d2041fa190bbb1be93526233795fdfba4ca6f4ec6fe015a69dc17a2cbc0cd
|
7
|
+
data.tar.gz: 369fce7367f1cc72394d052a722955a545302a7429ceab1bcd38ffcec81e7c5945a90322383e757dffadc0ec2501ba188eee71bd41157f5adc3fc623ec645aed
|
@@ -0,0 +1,49 @@
|
|
1
|
+
version: 2
|
2
|
+
|
3
|
+
steps: &steps
|
4
|
+
steps:
|
5
|
+
- checkout
|
6
|
+
- run: bundle install
|
7
|
+
- run: bundle exec rake
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
ruby-2.4:
|
11
|
+
docker:
|
12
|
+
- image: circleci/ruby:2.4
|
13
|
+
<<: *steps
|
14
|
+
|
15
|
+
ruby-2.5:
|
16
|
+
docker:
|
17
|
+
- image: circleci/ruby:2.5
|
18
|
+
<<: *steps
|
19
|
+
|
20
|
+
ruby-2.6:
|
21
|
+
docker:
|
22
|
+
- image: circleci/ruby:2.6
|
23
|
+
<<: *steps
|
24
|
+
|
25
|
+
ruby-2.7:
|
26
|
+
docker:
|
27
|
+
- image: circleci/ruby:2.7
|
28
|
+
<<: *steps
|
29
|
+
|
30
|
+
ruby-3.0:
|
31
|
+
docker:
|
32
|
+
- image: circleci/ruby:3.0
|
33
|
+
<<: *steps
|
34
|
+
|
35
|
+
ruby-head:
|
36
|
+
docker:
|
37
|
+
- image: rubocophq/circleci-ruby-snapshot:latest
|
38
|
+
<<: *steps
|
39
|
+
|
40
|
+
workflows:
|
41
|
+
version: 2
|
42
|
+
build:
|
43
|
+
jobs:
|
44
|
+
- ruby-2.4
|
45
|
+
- ruby-2.5
|
46
|
+
- ruby-2.6
|
47
|
+
- ruby-2.7
|
48
|
+
- ruby-3.0
|
49
|
+
- ruby-head
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Masataka Pocke Kuwabara
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
-
#
|
1
|
+
# RuboCop Rubycw
|
2
2
|
|
3
|
-
|
3
|
+
Integrate RuboCop and `ruby -cw`.
|
4
4
|
|
5
|
-
|
5
|
+
You can get Ruby's warning as a RuboCop offense by rubocop-rubycw.
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
* Ruby 2.3 or greater.
|
10
|
+
* But I highly recommend to use Ruby 2.6 or greater.
|
11
|
+
Because it is about 10x slower if it works on Ruby 2.5 or lower.
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
9
15
|
Add this line to your application's Gemfile:
|
10
16
|
|
11
17
|
```ruby
|
12
|
-
gem 'rubocop-rubycw'
|
18
|
+
gem 'rubocop-rubycw', require: false
|
13
19
|
```
|
14
20
|
|
15
21
|
And then execute:
|
@@ -22,7 +28,11 @@ Or install it yourself as:
|
|
22
28
|
|
23
29
|
## Usage
|
24
30
|
|
25
|
-
|
31
|
+
Put this into your `.rubocop.yml`.
|
32
|
+
|
33
|
+
```yaml
|
34
|
+
require: rubocop-rubycw
|
35
|
+
```
|
26
36
|
|
27
37
|
## Development
|
28
38
|
|
@@ -32,5 +42,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
42
|
|
33
43
|
## Contributing
|
34
44
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
45
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rubocop-hq/rubocop-rubycw.
|
36
46
|
|
data/lib/rubocop-rubycw.rb
CHANGED
@@ -1,31 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'open3'
|
4
|
-
require 'rbconfig'
|
5
|
-
|
6
3
|
module RuboCop
|
7
4
|
module Cop
|
8
5
|
module Rubycw
|
9
6
|
# Execute `ruby -cw` and wrap the warning as RuboCop offense.
|
10
|
-
class Rubycw <
|
7
|
+
class Rubycw < Base
|
11
8
|
include RangeHelp
|
12
9
|
|
13
|
-
def
|
10
|
+
def on_new_investigation
|
14
11
|
source = processed_source.raw_source
|
15
|
-
_stdout, stderr, _status = Open3.capture3(ruby, '-cw', '-e', source)
|
16
12
|
|
17
|
-
|
18
|
-
line.
|
19
|
-
|
20
|
-
message = line[/-e:\d+: warning: (.+)$/, 1]
|
13
|
+
warnings(source).each do |line|
|
14
|
+
lnum = line[/.+:(\d+):/, 1].to_i
|
15
|
+
message = line[/.+:\d+: warning: (.+)$/, 1]
|
21
16
|
|
22
17
|
range = source_range(processed_source.buffer, lnum, 0)
|
23
|
-
add_offense(range,
|
18
|
+
add_offense(range, message: message)
|
24
19
|
end
|
25
20
|
end
|
26
21
|
|
27
|
-
def
|
28
|
-
|
22
|
+
def warnings(source)
|
23
|
+
RuboCop::Rubycw::WarningCapturer.capture(source)
|
29
24
|
end
|
30
25
|
end
|
31
26
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Rubycw
|
5
|
+
module WarningCapturer
|
6
|
+
if defined?(RubyVM::AbstractSyntaxTree)
|
7
|
+
module ::Warning
|
8
|
+
def self.warn(*message)
|
9
|
+
if WarningCapturer.warnings
|
10
|
+
WarningCapturer.warnings.concat message
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.capture(source)
|
18
|
+
start
|
19
|
+
RubyVM::AbstractSyntaxTree.parse(source)
|
20
|
+
warnings
|
21
|
+
ensure
|
22
|
+
stop
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.start
|
26
|
+
@verbose = $VERBOSE
|
27
|
+
$VERBOSE = true
|
28
|
+
@warnings = []
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.stop
|
32
|
+
$VERBOSE = @verbose if defined?(@verbose)
|
33
|
+
@warnings = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.warnings
|
37
|
+
@warnings
|
38
|
+
end
|
39
|
+
|
40
|
+
stop
|
41
|
+
else
|
42
|
+
require 'rbconfig'
|
43
|
+
require 'open3'
|
44
|
+
|
45
|
+
def self.capture(source)
|
46
|
+
_stdout, stderr, _status = Open3.capture3(RbConfig.ruby, '-cw', stdin_data: source)
|
47
|
+
stderr.lines.map(&:chomp)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/rubocop-rubycw.gemspec
CHANGED
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
|
9
9
|
spec.summary = %q{Integrate RuboCop and ruby -cw}
|
10
10
|
spec.description = %q{Integrate RuboCop and ruby -cw}
|
11
|
-
spec.homepage = "https://github.com/
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
11
|
+
spec.homepage = "https://github.com/rubocop-hq/rubocop-rubycw"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
13
|
+
spec.license = 'MIT'
|
13
14
|
|
14
15
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
15
16
|
|
@@ -26,6 +27,5 @@ Gem::Specification.new do |spec|
|
|
26
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
28
|
spec.require_paths = ["lib"]
|
28
29
|
|
29
|
-
spec.add_runtime_dependency 'rubocop'
|
30
|
+
spec.add_runtime_dependency 'rubocop', '~> 1.0'
|
30
31
|
end
|
31
|
-
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rubycw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Pocke Kuwabara
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '1.0'
|
27
27
|
description: Integrate RuboCop and ruby -cw
|
28
28
|
email:
|
29
29
|
- kuwabara@pocke.me
|
@@ -31,10 +31,12 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- ".circleci/config.yml"
|
34
35
|
- ".gitignore"
|
35
36
|
- ".rspec"
|
36
37
|
- ".rubocop.yml"
|
37
38
|
- Gemfile
|
39
|
+
- LICENSE
|
38
40
|
- README.md
|
39
41
|
- Rakefile
|
40
42
|
- bin/console
|
@@ -46,13 +48,15 @@ files:
|
|
46
48
|
- lib/rubocop/rubycw.rb
|
47
49
|
- lib/rubocop/rubycw/inject.rb
|
48
50
|
- lib/rubocop/rubycw/version.rb
|
51
|
+
- lib/rubocop/rubycw/warning_capturer.rb
|
49
52
|
- rubocop-rubycw.gemspec
|
50
|
-
homepage: https://github.com/
|
51
|
-
licenses:
|
53
|
+
homepage: https://github.com/rubocop-hq/rubocop-rubycw
|
54
|
+
licenses:
|
55
|
+
- MIT
|
52
56
|
metadata:
|
53
|
-
homepage_uri: https://github.com/
|
54
|
-
source_code_uri: https://github.com/
|
55
|
-
post_install_message:
|
57
|
+
homepage_uri: https://github.com/rubocop-hq/rubocop-rubycw
|
58
|
+
source_code_uri: https://github.com/rubocop-hq/rubocop-rubycw
|
59
|
+
post_install_message:
|
56
60
|
rdoc_options: []
|
57
61
|
require_paths:
|
58
62
|
- lib
|
@@ -60,15 +64,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
64
|
requirements:
|
61
65
|
- - ">="
|
62
66
|
- !ruby/object:Gem::Version
|
63
|
-
version: 2.
|
67
|
+
version: 2.4.0
|
64
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
69
|
requirements:
|
66
70
|
- - ">="
|
67
71
|
- !ruby/object:Gem::Version
|
68
72
|
version: '0'
|
69
73
|
requirements: []
|
70
|
-
rubygems_version: 3.0.
|
71
|
-
signing_key:
|
74
|
+
rubygems_version: 3.3.0.dev
|
75
|
+
signing_key:
|
72
76
|
specification_version: 4
|
73
77
|
summary: Integrate RuboCop and ruby -cw
|
74
78
|
test_files: []
|