rubocop-cop-lint-positive_p 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: afc1f9ed2238a73fb3844192676d46b092dd7ac53ac7f391311366e403ec75f1
4
+ data.tar.gz: d1c6b9b83ba2534161635b595375f1ef25c067d9f97aeec207c93bb0c2953635
5
+ SHA512:
6
+ metadata.gz: 8b1bc1a38bce3c644ac1f03500a8ac7fcbfa7a3d1e0039cb2dd8d507f4d04fc4b3575eba2509546a550e90ff7eab5a071c29159eda5d342055b4feb598ca9abf
7
+ data.tar.gz: d4114c258127b23e6bce2ce26c154df72676fc449042dfb3bb0b773bd084c1e81b37c709505b287d6142ed6263edb3464d42e8db6f0d54fb99701e27364fdb77
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.7.0
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rubocop-cop-lint-positive_p.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubocop-cop-lint-positive_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-positive_p!
51
+
52
+ BUNDLED WITH
53
+ 2.0.1
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # RuboCop::Cop::Lint::PositiveP
2
+
3
+ This cop checks for method call Numeric#positive?
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-positive_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-positive_p
22
+
23
+ ## Usage
24
+
25
+ ```yaml
26
+ # .rubocop.yml
27
+ inherit_gem:
28
+ rubocop-cop-lint-positive_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-positive_p.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rubocop/cop/lint/positive_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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ require: rubocop/cop/lint/positive_p
2
+
3
+ Lint/PositiveP:
4
+ Description: Checks for method call Numeric#positive?
5
+ Enabled: true
6
+ Severity: error
@@ -0,0 +1,34 @@
1
+ require "rubocop"
2
+ require "rubocop/cop/lint/positive_p/version"
3
+
4
+ module RuboCop
5
+ module Cop
6
+ module Lint
7
+ # This cop checks for method call Numeric#positive?
8
+ #
9
+ # @example
10
+ # # bad
11
+ # 42.positive?
12
+ #
13
+ # # good
14
+ # 42 >= 0
15
+ class PositiveP < Cop
16
+ MSG = "Do not use Numeric#positive?"
17
+
18
+ def_node_matcher :positive?, <<-PATTERN
19
+ (send _ :positive?)
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 positive?(node)
28
+
29
+ add_offense(node)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ require "rubocop"
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Lint
6
+ class PositiveP < Cop
7
+ VERSION = "0.1.0"
8
+ end
9
+ end
10
+ end
11
+ 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/positive_p/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rubocop-cop-lint-positive_p"
8
+ spec.version = RuboCop::Cop::Lint::PositiveP::VERSION
9
+ spec.authors = ["Seiei Miyagi"]
10
+ spec.email = ["hanachin@gmail.com"]
11
+
12
+ spec.summary = %q{This cop checks for method call Numeric#positive?}
13
+ spec.homepage = "https://github.com/hanachin/rubocop-cop-lint-positive_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-positive_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/positive_p.rb
87
+ - lib/rubocop/cop/lint/positive_p/version.rb
88
+ - rubocop-cop-lint-positive_p.gemspec
89
+ homepage: https://github.com/hanachin/rubocop-cop-lint-positive_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#positive?
111
+ test_files: []