rubocop-rubycw 0.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.rubocop.yml +3 -0
- data/Gemfile +7 -0
- data/README.md +36 -0
- data/Rakefile +30 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/default.yml +5 -0
- data/lib/rubocop-rubycw.rb +11 -0
- data/lib/rubocop/cop/rubycw/rubycw.rb +33 -0
- data/lib/rubocop/cop/rubycw_cops.rb +2 -0
- data/lib/rubocop/rubycw.rb +14 -0
- data/lib/rubocop/rubycw/inject.rb +20 -0
- data/lib/rubocop/rubycw/version.rb +5 -0
- data/rubocop-rubycw.gemspec +31 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 60b45d27802b3ad9ac0f525498f2874c1a5ebab0d5b5546f1eda189ad67c9b27
|
4
|
+
data.tar.gz: 3b017269d8ac789d4f1b2b2bf6393fe2bbf295a3f53bc7034dbf79ee586432a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d13c09ef2e7d28bfb5af34c4526ae49c205aba2771bf0f440485325fab9f5309528c133eaf127b610ca61c7e6f92965e0a11ea3b843529c2a2e623277320732
|
7
|
+
data.tar.gz: a37de4fa589c706853da0332f945e33ace663488205cd6ea998497dcfaa82cd6396372900ed39a372d1746a94dbb485374444f3fa84e7d390874d37a4e4dcfdc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Rubocop::Rubycw
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rubocop/rubycw`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rubocop-rubycw'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rubocop-rubycw
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pocke/rubocop-rubycw.
|
36
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
task :default => :spec
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Generate a new cop with a template'
|
11
|
+
task :new_cop, [:cop] do |_task, args|
|
12
|
+
require 'rubocop'
|
13
|
+
|
14
|
+
cop_name = args.fetch(:cop) do
|
15
|
+
warn 'usage: bundle exec rake new_cop[Department/Name]'
|
16
|
+
exit!
|
17
|
+
end
|
18
|
+
|
19
|
+
github_user = `git config github.user`.chop
|
20
|
+
github_user = 'your_id' if github_user.empty?
|
21
|
+
|
22
|
+
generator = RuboCop::Cop::Generator.new(cop_name, github_user)
|
23
|
+
|
24
|
+
generator.write_source
|
25
|
+
generator.write_spec
|
26
|
+
generator.inject_require(root_file_path: 'lib/rubocop/cop/rubycw_cops.rb')
|
27
|
+
generator.inject_config(config_file_path: 'config/default.yml')
|
28
|
+
|
29
|
+
puts generator.todo
|
30
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rubocop/rubycw"
|
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
ADDED
data/config/default.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop'
|
4
|
+
|
5
|
+
require_relative 'rubocop/rubycw'
|
6
|
+
require_relative 'rubocop/rubycw/version'
|
7
|
+
require_relative 'rubocop/rubycw/inject'
|
8
|
+
|
9
|
+
RuboCop::Rubycw::Inject.defaults!
|
10
|
+
|
11
|
+
require_relative 'rubocop/cop/rubycw_cops'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
module RuboCop
|
7
|
+
module Cop
|
8
|
+
module Rubycw
|
9
|
+
# Execute `ruby -cw` and wrap the warning as RuboCop offense.
|
10
|
+
class Rubycw < Cop
|
11
|
+
include RangeHelp
|
12
|
+
|
13
|
+
def investigate(processed_source)
|
14
|
+
source = processed_source.raw_source
|
15
|
+
_stdout, stderr, _status = Open3.capture3(ruby, '-cw', '-e', source)
|
16
|
+
|
17
|
+
stderr.each_line do |line|
|
18
|
+
line.chomp!
|
19
|
+
lnum = line[/-e:(\d+):/, 1].to_i
|
20
|
+
message = line[/-e:\d+: warning: (.+)$/, 1]
|
21
|
+
|
22
|
+
range = source_range(processed_source.buffer, lnum, 0)
|
23
|
+
add_offense(range, location: range, message: message)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def ruby
|
28
|
+
RbConfig.ruby
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "rubocop/rubycw/version"
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Rubycw
|
5
|
+
class Error < StandardError; end
|
6
|
+
# Your code goes here...
|
7
|
+
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
8
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
9
|
+
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
10
|
+
|
11
|
+
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The original code is from https://github.com/rubocop-hq/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
|
4
|
+
# See https://github.com/rubocop-hq/rubocop-rspec/blob/master/MIT-LICENSE.md
|
5
|
+
module RuboCop
|
6
|
+
module Rubycw
|
7
|
+
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
8
|
+
# bit of our configuration.
|
9
|
+
module Inject
|
10
|
+
def self.defaults!
|
11
|
+
path = CONFIG_DEFAULT.to_s
|
12
|
+
hash = ConfigLoader.send(:load_yaml_configuration, path)
|
13
|
+
config = Config.new(hash, path)
|
14
|
+
puts "configuration from #{path}" if ConfigLoader.debug?
|
15
|
+
config = ConfigLoader.merge_with_default(config, path)
|
16
|
+
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'lib/rubocop/rubycw/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "rubocop-rubycw"
|
5
|
+
spec.version = RuboCop::Rubycw::VERSION
|
6
|
+
spec.authors = ["Masataka Pocke Kuwabara"]
|
7
|
+
spec.email = ["kuwabara@pocke.me"]
|
8
|
+
|
9
|
+
spec.summary = %q{Integrate RuboCop and ruby -cw}
|
10
|
+
spec.description = %q{Integrate RuboCop and ruby -cw}
|
11
|
+
spec.homepage = "https://github.com/pocke/rubocop-rubycw"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
18
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_runtime_dependency 'rubocop'
|
30
|
+
end
|
31
|
+
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubocop-rubycw
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masataka Pocke Kuwabara
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Integrate RuboCop and ruby -cw
|
28
|
+
email:
|
29
|
+
- kuwabara@pocke.me
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
36
|
+
- ".rubocop.yml"
|
37
|
+
- Gemfile
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- bin/console
|
41
|
+
- bin/setup
|
42
|
+
- config/default.yml
|
43
|
+
- lib/rubocop-rubycw.rb
|
44
|
+
- lib/rubocop/cop/rubycw/rubycw.rb
|
45
|
+
- lib/rubocop/cop/rubycw_cops.rb
|
46
|
+
- lib/rubocop/rubycw.rb
|
47
|
+
- lib/rubocop/rubycw/inject.rb
|
48
|
+
- lib/rubocop/rubycw/version.rb
|
49
|
+
- rubocop-rubycw.gemspec
|
50
|
+
homepage: https://github.com/pocke/rubocop-rubycw
|
51
|
+
licenses: []
|
52
|
+
metadata:
|
53
|
+
homepage_uri: https://github.com/pocke/rubocop-rubycw
|
54
|
+
source_code_uri: https://github.com/pocke/rubocop-rubycw
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.3.0
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubygems_version: 3.0.3
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Integrate RuboCop and ruby -cw
|
74
|
+
test_files: []
|