Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d67f3bd
commit 4bed899
Showing
7 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: rubocop-packaging | ||
title: RuboCop Packaging | ||
version: master | ||
nav: | ||
- modules/ROOT/nav.adoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* xref:index.adoc[Home] | ||
* xref:installation.adoc[Installation] | ||
* xref:usage.adoc[Usage] | ||
* xref:cops.adoc[Cops] | ||
* Cops Documentation | ||
** xref:cops_packaging.adoc[Packaging] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// START_COP_LIST | ||
|
||
= Department xref:cops_packaging.adoc[Packaging] | ||
|
||
* xref:cops_packaging.adoc#packaginggemspecgit[Packaging/GemspecGit] | ||
|
||
// END_COP_LIST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
= Packaging | ||
|
||
== Packaging/GemspecGit | ||
|
||
|=== | ||
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | ||
|
||
| Enabled | ||
| Yes | ||
| No | ||
| 0.86 | ||
| - | ||
|=== | ||
|
||
This cop is used to identify the usage of `git ls-files` | ||
and suggests to use a plain Ruby alternative, like `Dir`, | ||
`Dir.glob` or `Rake::FileList` instead. | ||
|
||
=== Examples | ||
|
||
[source,ruby] | ||
---- | ||
# bad | ||
Gem::Specification.new do |spec| | ||
spec.files = `git ls-files`.split('\n') | ||
end | ||
# bad | ||
Gem::Specification.new do |spec| | ||
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do | ||
`git ls-files -z`.split('\\x0').reject { |f| f.match(%r{^(test|spec|features)/}) } | ||
end | ||
end | ||
# bad | ||
Gem::Specification.new do |spec| | ||
spec.files = `git ls-files`.split('\n') | ||
spec.test_files = `git ls-files -- test/{functional,unit}/*`.split('\n') | ||
spec.executables = `git ls-files -- bin/*`.split('\n').map{ |f| File.basename(f) } | ||
end | ||
# good | ||
Gem::Specification.new do |spec| | ||
spec.files = Dir['lib/**/*', 'LICENSE', 'README.md'] | ||
spec.test_files = Dir['spec/**/*'] | ||
end | ||
# good | ||
Gem::Specification.new do |spec| | ||
spec.files = Rake::FileList['**/*'].exclude(*File.read('.gitignore').split) | ||
end | ||
# good | ||
Gem::Specification.new do |spec| | ||
spec.files = Dir.glob('lib/**/*') | ||
spec.test_files = Dir.glob('test/{functional,test}/*') | ||
spec.executables = Dir.glob('bin/*').map{ |f| File.basename(f) } | ||
end | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
= RuboCop Packaging | ||
|
||
`RuboCop::Packaging` is an extension of [RuboCop](https://rubocop.org/), | ||
which is a Ruby static code analyzer (a.k.a. linter) and code formatter. | ||
|
||
It contains a set of Cops which enforces some of the guidelines that | ||
are expected of upstream maintainers so that the downstream can build | ||
their packages in a clean environment without any problems. | ||
Some of the other basic guidelines can be found | ||
[here](https://wiki.debian.org/Teams/Ruby/RubyExtras/UpstreamDevelopers). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
= Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
[source,ruby] | ||
---- | ||
gem 'rubocop-packaging', require: false | ||
---- | ||
|
||
And then execute: | ||
|
||
[source,bash] | ||
---- | ||
$ bundle install | ||
---- | ||
|
||
Or install it yourself as: | ||
|
||
[source,bash] | ||
---- | ||
$ gem install rubocop-packaging | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
= Usage | ||
|
||
You need to tell RuboCop to load the Packaging extension. There are three | ||
ways to do this: | ||
|
||
== RuboCop configuration file | ||
|
||
Put this into your `.rubocop.yml` file: | ||
|
||
[source,yaml] | ||
---- | ||
require: rubocop-packaging | ||
---- | ||
|
||
Alternatively, use the following array notation when specifying multiple | ||
extensions: | ||
|
||
[source,yaml] | ||
---- | ||
require: | ||
- rubocop-other-extension | ||
- rubocop-packaging | ||
---- | ||
|
||
Now you can run `rubocop` and it will automatically load the RuboCop Packaging | ||
cops together with the standard cops. | ||
|
||
== Command line | ||
|
||
[source,bash] | ||
---- | ||
rubocop --require rubocop-packaging | ||
---- | ||
|
||
== Rake task | ||
|
||
[source,ruby] | ||
---- | ||
RuboCop::RakeTask.new do |task| | ||
task.requires << 'rubocop-packaging' | ||
end | ||
---- |