super_awesome_print_rubocop 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 461520acb72e7858ca4ef5d9b80219caba363b62
4
- data.tar.gz: b1ddda0d620cc4edbedcacce7be2a68552a72496
2
+ SHA256:
3
+ metadata.gz: 9dca280edee9a1f1aaba324ef718998b1004a6ee3cccf67009ef01173e7d0e64
4
+ data.tar.gz: '03892ad7e7e1a204d55143f3d4bd2066f5acb594e0c73fe24f4751e3c12bfcd6'
5
5
  SHA512:
6
- metadata.gz: 97dc862c3ebac9da345841d325cedece02719c984e6d5861a2ac7249a90d0992b40cd8ccbaa4678f9614a745a7df27f617ec59fb97c151a4e563397361c7aa69
7
- data.tar.gz: a50a78804e2e354cb87ca40b7760cc1dabd6cdaa7b6e4d591b419181d6b1dc0f0ce804dcf37d06f7a969964694ac19b76f98729aa90dfcc1160637f9c747b55c
6
+ metadata.gz: 6c33e17b876ff1f26c4f6c25429eb3face5f5d48e73d9eb3ec6f4a136590f9d9c88aafb1a37aba0c67889bc705f35924460c8172315cc83bf9df74c64673d3be
7
+ data.tar.gz: 626998f6147c729256a92834572435585bbbfe0a9b5c81cb3108a2d3065564d0340db61e2be19c2df72a822b3efa488c60665b3b789087cd8bbcbf4a43124713
data/README.md CHANGED
@@ -1,48 +1,70 @@
1
1
  # SuperAwesomePrintRubocop
2
2
 
3
- RuboCop's cop for https://github.com/olegantonyan/super_awesome_print.
4
- rubocop will fail if you have `sap` in the code.
3
+ [![CI](https://github.com/olegantonyan/super_awesome_print_rubocop/actions/workflows/ci.yml/badge.svg)](https://github.com/olegantonyan/super_awesome_print_rubocop/actions/workflows/ci.yml)
4
+
5
+ A [RuboCop](https://rubocop.org) cop that flags leftover `sap` and `sapf` debug calls from [super_awesome_print](https://github.com/olegantonyan/super_awesome_print), so they don't reach production.
6
+
7
+ Requires Ruby 2.7+ and RuboCop 1.0+.
5
8
 
6
9
  ## Installation
7
10
 
8
11
  Add this line to your application's Gemfile:
9
12
 
10
13
  ```ruby
11
- gem 'super_awesome_print_rubocop'
14
+ gem 'super_awesome_print_rubocop', require: false
12
15
  ```
13
16
 
14
- And then execute:
17
+ And then run:
15
18
 
16
- $ bundle
19
+ $ bundle install
17
20
 
18
- Or install it yourself as:
21
+ Or install it yourself:
19
22
 
20
23
  $ gem install super_awesome_print_rubocop
21
24
 
22
- Add this line to your `rubocop.yml`:
25
+ Enable it in `.rubocop.yml`. On RuboCop 1.72 or newer:
23
26
 
24
- ```ruby
25
- require: 'super_awesome_print_rubocop'
27
+ ```yaml
28
+ plugins:
29
+ - super_awesome_print_rubocop
30
+ ```
31
+
32
+ On older RuboCop:
33
+
34
+ ```yaml
35
+ require:
36
+ - super_awesome_print_rubocop
26
37
  ```
27
38
 
28
39
  ## Usage
29
40
 
30
- Run `rubocop` as usual. It should fail if you have `sap` call in your code.
41
+ Run `rubocop` as usual. It reports every `sap` or `sapf` call, including `self.sap`:
42
+
43
+ ```
44
+ app/controllers/posts_controller.rb:3:3: C: SuperAwesomePrint/Avoid: Avoid sap in production.
45
+ sap @posts
46
+ ^^^^^^^^^^
47
+ ```
31
48
 
32
49
  ## Development
33
50
 
34
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
+ After checking out the repo, run `bin/setup` to install dependencies, then `bundle exec rake test` to run the tests. Run `bin/console` for an interactive prompt.
52
+
53
+ To test against a specific RuboCop version, set `RUBOCOP_VERSION` to a version requirement. Older RuboCop versions may need an older Ruby (CI runs RuboCop 1.0 on Ruby 2.7):
54
+
55
+ $ RUBOCOP_VERSION='~> 1.71.0' bundle update rubocop
56
+ $ RUBOCOP_VERSION='~> 1.71.0' bundle exec rake test
35
57
 
36
- 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).
58
+ 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`, then run `bundle exec rake release`. This creates a git tag for the version, pushes git commits and tags, and pushes the `.gem` file to [rubygems.org](https://rubygems.org).
37
59
 
38
60
  ## Contributing
39
61
 
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/super_awesome_print_rubocop. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
62
+ Bug reports and pull requests are welcome on GitHub at https://github.com/olegantonyan/super_awesome_print_rubocop. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://www.contributor-covenant.org) code of conduct.
41
63
 
42
64
  ## License
43
65
 
44
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
66
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
45
67
 
46
68
  ## Code of Conduct
47
69
 
48
- Everyone interacting in the SuperAwesomePrintRubocop projects codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/olegantonyan/super_awesome_print_rubocop/blob/master/CODE_OF_CONDUCT.md).
70
+ Everyone interacting in the SuperAwesomePrintRubocop project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/olegantonyan/super_awesome_print_rubocop/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,3 @@
1
+ SuperAwesomePrint/Avoid:
2
+ Description: 'Checks for leftover `sap` and `sapf` debug calls.'
3
+ Enabled: true
@@ -1,20 +1,18 @@
1
- require 'rubocop'
2
-
3
1
  module RuboCop
4
2
  module Cop
5
3
  module SuperAwesomePrint
6
- class Avoid < Cop # rubocop:disable Style/Documentation
7
- MSG = 'Avoid `sap` and `sapf` in production'.freeze
4
+ class Avoid < Base
5
+ MSG = 'Avoid `%<method>s` in production.'.freeze
6
+ RESTRICT_ON_SEND = %i[sap sapf].freeze
8
7
 
9
- def_node_matcher :sap?, <<-END
10
- (send nil
11
- {:sap :sapf}
12
- ...)
13
- END
8
+ def_node_matcher :sap_call?, <<-PATTERN
9
+ (send {nil? self} {:sap :sapf} ...)
10
+ PATTERN
14
11
 
15
12
  def on_send(node)
16
- return unless sap?(node)
17
- add_offense(node, :expression, format(MSG, node.source))
13
+ return unless sap_call?(node)
14
+
15
+ add_offense(node, message: format(MSG, method: node.method_name))
18
16
  end
19
17
  end
20
18
  end
@@ -0,0 +1,26 @@
1
+ require 'lint_roller'
2
+
3
+ module SuperAwesomePrintRubocop
4
+ class Plugin < LintRoller::Plugin
5
+ def about
6
+ LintRoller::About.new(
7
+ name: 'super_awesome_print_rubocop',
8
+ version: VERSION,
9
+ homepage: 'https://github.com/olegantonyan/super_awesome_print_rubocop',
10
+ description: 'Flags leftover super_awesome_print debug calls (`sap`, `sapf`).'
11
+ )
12
+ end
13
+
14
+ def supported?(context)
15
+ context.engine == :rubocop
16
+ end
17
+
18
+ def rules(_context)
19
+ LintRoller::Rules.new(
20
+ type: :path,
21
+ config_format: :rubocop,
22
+ value: File.expand_path('../../../config/default.yml', __dir__)
23
+ )
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module SuperAwesomePrintRubocop
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -1,2 +1,4 @@
1
+ require 'rubocop'
1
2
  require 'rubocop/super_awesome_print_rubocop/version'
3
+ require 'rubocop/super_awesome_print_rubocop/plugin'
2
4
  require 'rubocop/cop/super_awesome_print/avoid'
metadata CHANGED
@@ -1,97 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_awesome_print_rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Antonyan
8
- autorequire:
9
- bindir: exe
8
+ bindir: bin
10
9
  cert_chain: []
11
- date: 2017-09-04 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: bundler
13
+ name: lint_roller
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '1.15'
20
- type: :development
18
+ version: '1.1'
19
+ type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '1.15'
25
+ version: '1.1'
27
26
  - !ruby/object:Gem::Dependency
28
- name: rake
27
+ name: rubocop
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - "~>"
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
32
+ version: '1.0'
33
+ type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - "~>"
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: '10.0'
39
+ version: '1.0'
41
40
  - !ruby/object:Gem::Dependency
42
- name: rspec
41
+ name: minitest
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - "~>"
44
+ - - ">="
46
45
  - !ruby/object:Gem::Version
47
- version: '3.0'
46
+ version: '0'
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - "~>"
51
+ - - ">="
53
52
  - !ruby/object:Gem::Version
54
- version: '3.0'
53
+ version: '0'
55
54
  - !ruby/object:Gem::Dependency
56
- name: rubocop
55
+ name: rake
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ">="
60
59
  - !ruby/object:Gem::Version
61
60
  version: '0'
62
- type: :runtime
61
+ type: :development
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - ">="
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
69
- description: Ensure you do not have `sap` in production from SuperAwesomePrint gem
68
+ description: Flags leftover `sap` and `sapf` calls from the super_awesome_print gem.
70
69
  email:
71
70
  - oleg.b.antonyan@gmail.com
72
71
  executables: []
73
72
  extensions: []
74
73
  extra_rdoc_files: []
75
74
  files:
76
- - ".gitignore"
77
- - ".rspec"
78
- - ".travis.yml"
79
- - CODE_OF_CONDUCT.md
80
- - Gemfile
81
75
  - LICENSE.txt
82
76
  - README.md
83
- - Rakefile
84
- - bin/console
85
- - bin/setup
77
+ - config/default.yml
86
78
  - lib/rubocop/cop/super_awesome_print/avoid.rb
79
+ - lib/rubocop/super_awesome_print_rubocop/plugin.rb
87
80
  - lib/rubocop/super_awesome_print_rubocop/version.rb
88
81
  - lib/super_awesome_print_rubocop.rb
89
- - super_awesome_print_rubocop.gemspec
90
- homepage: http://github.com/olegantonyan/super_awesome_print_rubocop
82
+ homepage: https://github.com/olegantonyan/super_awesome_print_rubocop
91
83
  licenses:
92
84
  - MIT
93
- metadata: {}
94
- post_install_message:
85
+ metadata:
86
+ default_lint_roller_plugin: SuperAwesomePrintRubocop::Plugin
95
87
  rdoc_options: []
96
88
  require_paths:
97
89
  - lib
@@ -99,16 +91,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
91
  requirements:
100
92
  - - ">="
101
93
  - !ruby/object:Gem::Version
102
- version: '0'
94
+ version: '2.7'
103
95
  required_rubygems_version: !ruby/object:Gem::Requirement
104
96
  requirements:
105
97
  - - ">="
106
98
  - !ruby/object:Gem::Version
107
99
  version: '0'
108
100
  requirements: []
109
- rubyforge_project:
110
- rubygems_version: 2.5.2
111
- signing_key:
101
+ rubygems_version: 4.0.16
112
102
  specification_version: 4
113
- summary: Ensure you do not have `sap` in production from SuperAwesomePrint gem
103
+ summary: RuboCop cop that keeps super_awesome_print debug calls out of your code
114
104
  test_files: []
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.4
5
- before_install: gem install bundler -v 1.15.3
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at oleg.b.antonyan@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in super_awesome_print_rubocop.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
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 DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "super_awesome_print_rubocop"
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 DELETED
@@ -1,8 +0,0 @@
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
@@ -1,29 +0,0 @@
1
- # coding: utf-8
2
- lib = ::File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rubocop/super_awesome_print_rubocop/version'
5
-
6
- ::Gem::Specification.new do |spec|
7
- spec.name = 'super_awesome_print_rubocop'
8
- spec.version = ::SuperAwesomePrintRubocop::VERSION
9
- spec.authors = ['Oleg Antonyan']
10
- spec.email = ['oleg.b.antonyan@gmail.com']
11
-
12
- spec.summary = 'Ensure you do not have `sap` in production from SuperAwesomePrint gem'
13
- spec.description = 'Ensure you do not have `sap` in production from SuperAwesomePrint gem'
14
- spec.homepage = 'http://github.com/olegantonyan/super_awesome_print_rubocop'
15
- spec.license = 'MIT'
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- 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_development_dependency 'bundler', '~> 1.15'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec', '~> 3.0'
27
-
28
- spec.add_dependency 'rubocop'
29
- end