rubocop-rubycw 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +44 -0
- data/README.md +8 -4
- data/lib/rubocop-rubycw.rb +1 -0
- data/lib/rubocop/cop/rubycw/rubycw.rb +5 -10
- data/lib/rubocop/rubycw/version.rb +1 -1
- data/lib/rubocop/rubycw/warning_capturer.rb +54 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87fd1bec83b5aa40bb75389248446b77be192dae8e6cd995459f39568d78f677
|
4
|
+
data.tar.gz: fe7852ed6d94b11292258597015e5035387177c54001417f59cc4ae61009a600
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9149d4541c6252ffae31f4f6194184779e67a88493bc642f867529d7761a2a1691bbf80e297f14b40d56a7b8d026e82faee57f9990cf68a479897013d0d5f4df
|
7
|
+
data.tar.gz: 858e238744ce39b500106a1e97e536687d3acc6f1887df39268033edbb7fd66604be9366aa0c505e93527d0551414eb87fdc638146a4a2a7789dab523eb9a089
|
@@ -0,0 +1,44 @@
|
|
1
|
+
version: 2
|
2
|
+
|
3
|
+
steps: &steps
|
4
|
+
steps:
|
5
|
+
- checkout
|
6
|
+
- run: bundle install
|
7
|
+
- run: bundle exec rake
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
|
11
|
+
ruby-2.3:
|
12
|
+
docker:
|
13
|
+
- image: circleci/ruby:2.3
|
14
|
+
<<: *steps
|
15
|
+
|
16
|
+
ruby-2.4:
|
17
|
+
docker:
|
18
|
+
- image: circleci/ruby:2.4
|
19
|
+
<<: *steps
|
20
|
+
|
21
|
+
ruby-2.5:
|
22
|
+
docker:
|
23
|
+
- image: circleci/ruby:2.5
|
24
|
+
<<: *steps
|
25
|
+
|
26
|
+
ruby-2.6:
|
27
|
+
docker:
|
28
|
+
- image: circleci/ruby:2.6
|
29
|
+
<<: *steps
|
30
|
+
|
31
|
+
ruby-head:
|
32
|
+
docker:
|
33
|
+
- image: rubocophq/circleci-ruby-snapshot:latest
|
34
|
+
<<: *steps
|
35
|
+
|
36
|
+
workflows:
|
37
|
+
version: 2
|
38
|
+
build:
|
39
|
+
jobs:
|
40
|
+
- ruby-2.3
|
41
|
+
- ruby-2.4
|
42
|
+
- ruby-2.5
|
43
|
+
- ruby-2.6
|
44
|
+
- ruby-head
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
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
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,7 +22,11 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Put this into your `.rubocop.yml`.
|
26
|
+
|
27
|
+
```yaml
|
28
|
+
require: rubocop-rubycw
|
29
|
+
```
|
26
30
|
|
27
31
|
## Development
|
28
32
|
|
data/lib/rubocop-rubycw.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
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
|
@@ -12,20 +9,18 @@ module RuboCop
|
|
12
9
|
|
13
10
|
def investigate(processed_source)
|
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
18
|
add_offense(range, location: 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,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Rubycw
|
5
|
+
module WarningCapturer
|
6
|
+
if defined?(RubyVM::AbstractSyntaxTree)
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
module ::Warning
|
10
|
+
def warn(*message)
|
11
|
+
if WarningCapturer.warnings
|
12
|
+
WarningCapturer.warnings.concat message
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.capture(source)
|
20
|
+
start
|
21
|
+
RubyVM::AbstractSyntaxTree.parse(source)
|
22
|
+
warnings
|
23
|
+
ensure
|
24
|
+
stop
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.start
|
28
|
+
@verbose = $VERBOSE
|
29
|
+
$VERBOSE = true
|
30
|
+
@warnings = []
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.stop
|
34
|
+
$VERBOSE = @verbose if defined?(@verbose)
|
35
|
+
@warnings = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.warnings
|
39
|
+
@warnings
|
40
|
+
end
|
41
|
+
|
42
|
+
stop
|
43
|
+
else
|
44
|
+
require 'rbconfig'
|
45
|
+
require 'open3'
|
46
|
+
|
47
|
+
def self.capture(source)
|
48
|
+
_stdout, stderr, _status = Open3.capture3(RbConfig.ruby, '-cw', '-e', source)
|
49
|
+
stderr.lines.map(&:chomp)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Pocke Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -31,6 +31,7 @@ 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"
|
@@ -46,6 +47,7 @@ files:
|
|
46
47
|
- lib/rubocop/rubycw.rb
|
47
48
|
- lib/rubocop/rubycw/inject.rb
|
48
49
|
- lib/rubocop/rubycw/version.rb
|
50
|
+
- lib/rubocop/rubycw/warning_capturer.rb
|
49
51
|
- rubocop-rubycw.gemspec
|
50
52
|
homepage: https://github.com/pocke/rubocop-rubycw
|
51
53
|
licenses: []
|