gemfilelint 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +13 -6
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +12 -11
- data/LICENSE +1 -1
- data/README.md +12 -4
- data/Rakefile +5 -5
- data/bin/console +3 -3
- data/exe/gemfilelint +20 -4
- data/gemfilelint.gemspec +13 -13
- data/lib/gemfilelint/version.rb +1 -1
- data/lib/gemfilelint.rb +19 -16
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2060f4fc9182c112139acb209f01d2e33912b25508f0685f75b78733daad2b
|
4
|
+
data.tar.gz: bf61bd673a5163aecf6f1dd2d150379fc809ecdf6a9e0067ce62473e0cf2d657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4130ead8d9a8b793b1cece83a2bfdae070225c5495370857acd5dc06adab2f4dae6af93bb74ee5dfe16415b82b8bc0d13887b6d6be5f0574e0e79c7fb3d58e42
|
7
|
+
data.tar.gz: c46f5cdaace8230cd21c1c1b981a42031db5a93bacc0f788e366a990b63bc35cb91033c8f38649820a52a670e8ffefeb9957fda699c9ed1a78c59d516a062e22
|
data/.rubocop.yml
CHANGED
@@ -2,6 +2,8 @@ AllCops:
|
|
2
2
|
DisplayCopNames: true
|
3
3
|
DisplayStyleGuide: true
|
4
4
|
TargetRubyVersion: 2.7
|
5
|
+
NewCops: enable
|
6
|
+
SuggestExtensions: false
|
5
7
|
Exclude:
|
6
8
|
- 'vendor/**/*'
|
7
9
|
|
@@ -14,5 +16,8 @@ Style/Documentation:
|
|
14
16
|
Style/ExplicitBlockArgument:
|
15
17
|
Enabled: false
|
16
18
|
|
19
|
+
Style/StringLiterals:
|
20
|
+
EnforcedStyle: double_quotes
|
21
|
+
|
17
22
|
Style/StructInheritance:
|
18
23
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.4.0] - 2021-09-15
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Support the `--ignore` option for removing false positives from the lint run.
|
14
|
+
|
9
15
|
## [0.3.0] - 2021-03-29
|
10
16
|
|
11
17
|
### Changed
|
@@ -36,9 +42,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
36
42
|
|
37
43
|
- 🎉 Initial release.
|
38
44
|
|
39
|
-
[unreleased]: https://github.com/
|
40
|
-
[0.
|
41
|
-
[0.
|
42
|
-
[0.2.
|
43
|
-
[0.2.
|
44
|
-
[0.
|
45
|
+
[unreleased]: https://github.com/kddnewton/gemfilelint/compare/v0.4.0...HEAD
|
46
|
+
[0.4.0]: https://github.com/kddnewton/gemfilelint/compare/v0.3.0...v0.4.0
|
47
|
+
[0.3.0]: https://github.com/kddnewton/gemfilelint/compare/v0.2.2...v0.3.0
|
48
|
+
[0.2.2]: https://github.com/kddnewton/gemfilelint/compare/v0.2.1...v0.2.2
|
49
|
+
[0.2.1]: https://github.com/kddnewton/gemfilelint/compare/v0.2.0...v0.2.1
|
50
|
+
[0.2.0]: https://github.com/kddnewton/gemfilelint/compare/v0.1.0...v0.2.0
|
51
|
+
[0.1.0]: https://github.com/kddnewton/gemfilelint/compare/935da5...v0.1.0
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at
|
58
|
+
reported by contacting the project team at kddnewton@gmail.com. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gemfilelint (0.
|
4
|
+
gemfilelint (0.4.0)
|
5
5
|
bundler
|
6
6
|
|
7
7
|
GEM
|
@@ -9,29 +9,30 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
ast (2.4.2)
|
11
11
|
minitest (5.14.4)
|
12
|
-
parallel (1.
|
13
|
-
parser (3.0.
|
12
|
+
parallel (1.21.0)
|
13
|
+
parser (3.0.2.0)
|
14
14
|
ast (~> 2.4.1)
|
15
15
|
rainbow (3.0.0)
|
16
|
-
rake (13.0.
|
16
|
+
rake (13.0.6)
|
17
17
|
regexp_parser (2.1.1)
|
18
|
-
rexml (3.2.
|
19
|
-
rubocop (1.
|
18
|
+
rexml (3.2.5)
|
19
|
+
rubocop (1.21.0)
|
20
20
|
parallel (~> 1.10)
|
21
21
|
parser (>= 3.0.0.0)
|
22
22
|
rainbow (>= 2.2.2, < 4.0)
|
23
23
|
regexp_parser (>= 1.8, < 3.0)
|
24
24
|
rexml
|
25
|
-
rubocop-ast (>= 1.
|
25
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
26
26
|
ruby-progressbar (~> 1.7)
|
27
27
|
unicode-display_width (>= 1.4.0, < 3.0)
|
28
|
-
rubocop-ast (1.
|
29
|
-
parser (>=
|
28
|
+
rubocop-ast (1.11.0)
|
29
|
+
parser (>= 3.0.1.1)
|
30
30
|
ruby-progressbar (1.11.0)
|
31
|
-
unicode-display_width (2.
|
31
|
+
unicode-display_width (2.1.0)
|
32
32
|
|
33
33
|
PLATFORMS
|
34
|
-
|
34
|
+
x86_64-darwin-19
|
35
|
+
x86_64-linux
|
35
36
|
|
36
37
|
DEPENDENCIES
|
37
38
|
gemfilelint!
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Gemfile lint
|
2
2
|
|
3
|
-
[![Build Status](https://github.com/
|
4
|
-
[![Gem Version](https://img.shields.io/gem/v/gemfilelint.svg)](https://github.com/
|
3
|
+
[![Build Status](https://github.com/kddnewton/gemfilelint/workflows/Main/badge.svg)](https://github.com/kddnewton/gemfilelint/actions)
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/gemfilelint.svg)](https://github.com/kddnewton/gemfilelint)
|
5
5
|
|
6
6
|
Lint your Gemfile! This will find common spelling mistakes in gems and remote sources so that you don't accidentally download code from places that you don't mean to. For example, if you have a Gemfile with the contents:
|
7
7
|
|
@@ -47,6 +47,14 @@ Or run the executable pointing to any number of gemfiles:
|
|
47
47
|
$ bundle exec gemfilelint gemfiles/*.gemfile
|
48
48
|
```
|
49
49
|
|
50
|
+
### --ignore
|
51
|
+
|
52
|
+
If you're receiving false positives because you're using a gem that is named similarly to a very popular gem, then you can pass the `--ignore` option to the CLI. This should be a comma-delimited list of gem names that should be ignored when linting. For example:
|
53
|
+
|
54
|
+
```
|
55
|
+
$ bundle exec gemfilelint --ignore rr
|
56
|
+
```
|
57
|
+
|
50
58
|
## Development
|
51
59
|
|
52
60
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -55,7 +63,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
55
63
|
|
56
64
|
## Contributing
|
57
65
|
|
58
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kddnewton/gemfilelint. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/kddnewton/gemfilelint/blob/master/CODE_OF_CONDUCT.md).
|
59
67
|
|
60
68
|
## License
|
61
69
|
|
@@ -63,4 +71,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
63
71
|
|
64
72
|
## Code of Conduct
|
65
73
|
|
66
|
-
Everyone interacting in the Gemfilelint project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
74
|
+
Everyone interacting in the Gemfilelint project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kddnewton/gemfilelint/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
5
|
|
6
6
|
Rake::TestTask.new(:test) do |t|
|
7
|
-
t.libs <<
|
8
|
-
t.libs <<
|
9
|
-
t.test_files = FileList[
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
10
|
end
|
11
11
|
|
12
12
|
task default: :test
|
data/bin/console
CHANGED
data/exe/gemfilelint
CHANGED
@@ -1,15 +1,31 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(
|
5
|
-
require 'gemfilelint'
|
4
|
+
$LOAD_PATH.unshift(File.expand_path(File.join("..", "lib"), __dir__))
|
6
5
|
|
7
|
-
|
6
|
+
require "gemfilelint"
|
7
|
+
require "optparse"
|
8
|
+
|
9
|
+
options = {}
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: gemfilelint [options] [path/to/Gemfile]*"
|
12
|
+
|
13
|
+
opts.on("-i GEMS", "--ignore GEMS", "Ignore a comma-delimited list of false positives") do |ignore|
|
14
|
+
options[:ignore] = ignore.split(",").map(&:strip)
|
15
|
+
end
|
8
16
|
|
17
|
+
opts.on("-h", "--help", "Prints this help") do
|
18
|
+
puts opts
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
end.parse!
|
22
|
+
|
23
|
+
gemfiles = ARGV.any? ? ARGV : %w[./Gemfile]
|
9
24
|
invalid = gemfiles.reject { |gemfile| File.file?(gemfile) }
|
25
|
+
|
10
26
|
if invalid.any?
|
11
27
|
warn("Could not find a gemfile at: #{invalid.join(', ')}")
|
12
28
|
exit 2
|
13
29
|
end
|
14
30
|
|
15
|
-
exit Gemfilelint.lint(*gemfiles) ? 0 : 1
|
31
|
+
exit Gemfilelint.lint(*gemfiles, **options) ? 0 : 1
|
data/gemfilelint.gemspec
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "lib/gemfilelint/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = "gemfilelint"
|
7
7
|
spec.version = Gemfilelint::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ["Kevin Newton"]
|
9
|
+
spec.email = ["kddnewton@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
11
|
+
spec.summary = "Lint your Gemfile!"
|
12
|
+
spec.homepage = "https://github.com/kddnewton/gemfilelint"
|
13
|
+
spec.license = "MIT"
|
14
14
|
|
15
15
|
spec.files = Dir.chdir(__dir__) do
|
16
16
|
`git ls-files -z`.split("\x0").reject do |f|
|
@@ -18,13 +18,13 @@ Gem::Specification.new do |spec|
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
spec.bindir =
|
21
|
+
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
-
spec.require_paths = [
|
23
|
+
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_dependency
|
25
|
+
spec.add_dependency "bundler"
|
26
26
|
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency "minitest"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "rubocop"
|
30
30
|
end
|
data/lib/gemfilelint/version.rb
CHANGED
data/lib/gemfilelint.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "delegate"
|
4
|
+
require "logger"
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "bundler"
|
7
|
+
require "bundler/similarity_detector"
|
8
8
|
|
9
|
-
require
|
9
|
+
require "gemfilelint/version"
|
10
10
|
|
11
11
|
module Gemfilelint
|
12
12
|
class SpellChecker
|
@@ -52,8 +52,10 @@ module Gemfilelint
|
|
52
52
|
|
53
53
|
module Parser
|
54
54
|
class Valid < Struct.new(:path, :dsl)
|
55
|
-
def each_offense
|
55
|
+
def each_offense(ignore: [])
|
56
56
|
dependencies.each do |dependency|
|
57
|
+
next if ignore.include?(dependency)
|
58
|
+
|
57
59
|
yield dependency_offense_for(dependency)
|
58
60
|
end
|
59
61
|
|
@@ -94,7 +96,7 @@ module Gemfilelint
|
|
94
96
|
end
|
95
97
|
|
96
98
|
class Invalid < Struct.new(:path)
|
97
|
-
def each_offense
|
99
|
+
def each_offense(**)
|
98
100
|
yield Offenses::InvalidGemfile.new(path)
|
99
101
|
end
|
100
102
|
end
|
@@ -119,9 +121,10 @@ module Gemfilelint
|
|
119
121
|
|
120
122
|
using ANSIColor
|
121
123
|
|
122
|
-
attr_reader :logger
|
124
|
+
attr_reader :ignore, :logger
|
123
125
|
|
124
|
-
def initialize(logger: nil)
|
126
|
+
def initialize(ignore: [], logger: nil)
|
127
|
+
@ignore = ignore
|
125
128
|
@logger = logger || make_logger
|
126
129
|
end
|
127
130
|
|
@@ -134,9 +137,9 @@ module Gemfilelint
|
|
134
137
|
each_offense_for(paths) do |offense|
|
135
138
|
if offense
|
136
139
|
offenses << offense
|
137
|
-
logger.info(
|
140
|
+
logger.info("W".colorize(:magenta))
|
138
141
|
else
|
139
|
-
logger.info(
|
142
|
+
logger.info(".".colorize(:green))
|
140
143
|
end
|
141
144
|
end
|
142
145
|
|
@@ -156,7 +159,7 @@ module Gemfilelint
|
|
156
159
|
|
157
160
|
def each_offense_for(paths)
|
158
161
|
paths.each do |path|
|
159
|
-
Parser.for(path).each_offense do |offense|
|
162
|
+
Parser.for(path).each_offense(ignore: ignore) do |offense|
|
160
163
|
yield offense
|
161
164
|
end
|
162
165
|
end
|
@@ -178,16 +181,16 @@ module Gemfilelint
|
|
178
181
|
def dependencies
|
179
182
|
@dependencies ||=
|
180
183
|
SpellChecker.new(
|
181
|
-
File.read(File.expand_path(
|
184
|
+
File.read(File.expand_path("gems.txt", __dir__)).split("\n")
|
182
185
|
)
|
183
186
|
end
|
184
187
|
|
185
188
|
def remotes
|
186
|
-
@remotes ||= SpellChecker.new([
|
189
|
+
@remotes ||= SpellChecker.new(["https://rubygems.org/"])
|
187
190
|
end
|
188
191
|
|
189
|
-
def lint(*paths, logger: nil)
|
190
|
-
Linter.new(logger: logger).lint(*paths)
|
192
|
+
def lint(*paths, ignore: [], logger: nil)
|
193
|
+
Linter.new(ignore: ignore, logger: logger).lint(*paths)
|
191
194
|
end
|
192
195
|
end
|
193
196
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemfilelint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Kevin
|
7
|
+
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
version: '0'
|
69
69
|
description:
|
70
70
|
email:
|
71
|
-
-
|
71
|
+
- kddnewton@gmail.com
|
72
72
|
executables:
|
73
73
|
- gemfilelint
|
74
74
|
extensions: []
|
@@ -93,7 +93,7 @@ files:
|
|
93
93
|
- lib/gemfilelint.rb
|
94
94
|
- lib/gemfilelint/version.rb
|
95
95
|
- lib/gems.txt
|
96
|
-
homepage: https://github.com/
|
96
|
+
homepage: https://github.com/kddnewton/gemfilelint
|
97
97
|
licenses:
|
98
98
|
- MIT
|
99
99
|
metadata: {}
|