rubocop-cop-lint-negative_p 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/default.yml +6 -0
- data/lib/rubocop/cop/lint/negative_p.rb +34 -0
- data/lib/rubocop/cop/lint/negative_p/version.rb +11 -0
- data/rubocop-cop-lint-negative_p.gemspec +28 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 16cb4e1b288cf7d8a13de6abaca77d69b7e45265174bfd7fd93cb3a0be36c2a5
|
4
|
+
data.tar.gz: c1bfcd7260f1919a53c255c087997bba80b9475b8303eacfa0e41e3f6a5ad46b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ddd4aff2708fca036461615d3b22ed737842719137ea7a678cd6149b4e9db69cb6845dc9505281e2b28bc141c9aaea660f953e95cee5dffd2974cf07deeabde
|
7
|
+
data.tar.gz: 87c97c23330352390ad0327beb2d5c595ba45e73d3817676f2facff185f6447846d31e5da012aa423e640632dcb3116f866d037255df89b5e1fde6599570438c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rubocop-cop-lint-negative_p (0.1.0)
|
5
|
+
rubocop
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.0)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
jaro_winkler (1.5.2)
|
13
|
+
parallel (1.12.1)
|
14
|
+
parser (2.5.3.0)
|
15
|
+
ast (~> 2.4.0)
|
16
|
+
powerpack (0.1.2)
|
17
|
+
rainbow (3.0.0)
|
18
|
+
rake (10.5.0)
|
19
|
+
rspec (3.8.0)
|
20
|
+
rspec-core (~> 3.8.0)
|
21
|
+
rspec-expectations (~> 3.8.0)
|
22
|
+
rspec-mocks (~> 3.8.0)
|
23
|
+
rspec-core (3.8.0)
|
24
|
+
rspec-support (~> 3.8.0)
|
25
|
+
rspec-expectations (3.8.2)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.8.0)
|
28
|
+
rspec-mocks (3.8.0)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.8.0)
|
31
|
+
rspec-support (3.8.0)
|
32
|
+
rubocop (0.62.0)
|
33
|
+
jaro_winkler (~> 1.5.1)
|
34
|
+
parallel (~> 1.10)
|
35
|
+
parser (>= 2.5, != 2.5.1.1)
|
36
|
+
powerpack (~> 0.1)
|
37
|
+
rainbow (>= 2.2.2, < 4.0)
|
38
|
+
ruby-progressbar (~> 1.7)
|
39
|
+
unicode-display_width (~> 1.4.0)
|
40
|
+
ruby-progressbar (1.10.0)
|
41
|
+
unicode-display_width (1.4.1)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
bundler (~> 2.0)
|
48
|
+
rake (~> 10.0)
|
49
|
+
rspec
|
50
|
+
rubocop-cop-lint-negative_p!
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
2.0.1
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# RuboCop::Cop::Lint::NegativeP
|
2
|
+
|
3
|
+
This cop checks for method call Numeric#negative?
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :development do
|
11
|
+
gem 'rubocop-cop-lint-negative_p', require: false
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rubocop-cop-lint-negative_p
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
# .rubocop.yml
|
27
|
+
inherit_gem:
|
28
|
+
rubocop-cop-lint-negative_p: config/default.yml
|
29
|
+
```
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
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.
|
34
|
+
|
35
|
+
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).
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hanachin/rubocop-cop-lint-negative_p.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rubocop/cop/lint/negative_p"
|
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,34 @@
|
|
1
|
+
require "rubocop"
|
2
|
+
require "rubocop/cop/lint/negative_p/version"
|
3
|
+
|
4
|
+
module RuboCop
|
5
|
+
module Cop
|
6
|
+
module Lint
|
7
|
+
# This cop checks for method call Numeric#negative?
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# 42.negative?
|
12
|
+
#
|
13
|
+
# # good
|
14
|
+
# 42 >= 0
|
15
|
+
class NegativeP < Cop
|
16
|
+
MSG = "Do not use Numeric#negative?"
|
17
|
+
|
18
|
+
def_node_matcher :negative?, <<-PATTERN
|
19
|
+
(send _ :negative?)
|
20
|
+
PATTERN
|
21
|
+
|
22
|
+
def self.support_target_ruby_version?(version)
|
23
|
+
version < 2.3
|
24
|
+
end
|
25
|
+
|
26
|
+
def on_send(node)
|
27
|
+
return unless negative?(node)
|
28
|
+
|
29
|
+
add_offense(node)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "rubocop/cop/lint/negative_p/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rubocop-cop-lint-negative_p"
|
8
|
+
spec.version = RuboCop::Cop::Lint::NegativeP::VERSION
|
9
|
+
spec.authors = ["Seiei Miyagi"]
|
10
|
+
spec.email = ["hanachin@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{This cop checks for method call Numeric#negative?}
|
13
|
+
spec.homepage = "https://github.com/hanachin/rubocop-cop-lint-negative_p"
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "rubocop"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubocop-cop-lint-negative_p
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Seiei Miyagi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-07 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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- hanachin@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- config/default.yml
|
86
|
+
- lib/rubocop/cop/lint/negative_p.rb
|
87
|
+
- lib/rubocop/cop/lint/negative_p/version.rb
|
88
|
+
- rubocop-cop-lint-negative_p.gemspec
|
89
|
+
homepage: https://github.com/hanachin/rubocop-cop-lint-negative_p
|
90
|
+
licenses: []
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.0.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: This cop checks for method call Numeric#negative?
|
111
|
+
test_files: []
|