Skip to content

Instantly share code, notes, and snippets.

@alvagante
Created August 29, 2017 16:49
Show Gist options
  • Save alvagante/94984de1e663f3eac29d8656221dfefb to your computer and use it in GitHub Desktop.
Save alvagante/94984de1e663f3eac29d8656221dfefb to your computer and use it in GitHub Desktop.
# Rubocop on a bran new pdk Gemfile:
al@lab tmp $ pdk new module sample --skip-interview
pdk (INFO): Creating new module: sample
al@lab tmp $ rubocop sample/Gemfile
Inspecting 1 file
C
Offenses:
sample/Gemfile:1:1: C: The name of this source file (Gemfile) should use snake_case.
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
^
sample/Gemfile:27:7: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
^^^^^^^^^^^^^^
sample/Gemfile:28:3: C: Gem fast_gettext requirements already given on line 27 of the Gemfile.
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sample/Gemfile:28:7: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
^^^^^^^^^^^^^^
sample/Gemfile:29:7: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
^^^^^^^^^^^
sample/Gemfile:30:3: C: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem json should appear before json_pure.
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sample/Gemfile:30:7: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
^^^^^^
sample/Gemfile:31:3: C: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem (str "puppet-module-posix-default-r") should appear before json.
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sample/Gemfile:123:5: C: The use of eval is a serious security risk.
eval(File.read(gemfile), binding)
^^^^
# Rubocop on psick Gemfile (derived from pdk) show a lot more:
al@lab psick [development] $ rubocop Gemfile
Inspecting 1 file
C
Offenses:
Gemfile:7:26: C: Use // around regular expression.
if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)}
^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:8:81: C: Line is too long. [103/80]
[fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact
^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:17:26: C: Use // around regular expression.
if place_or_version =~ %r{\Agit[:@]}
^^^^^^^^^^^^^
Gemfile:30:7: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
^^^^^^^^^^^^^^
Gemfile:30:81: C: Line is too long. [135/80]
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:31:3: C: Gem fast_gettext requirements already given on line 30 of the Gemfile.
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:31:7: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
^^^^^^^^^^^^^^
Gemfile:31:81: C: Line is too long. [136/80]
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:32:7: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
^^^^^^^^^^^
Gemfile:32:81: C: Line is too long. [135/80]
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:33:3: C: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem json should appear before json_pure.
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:33:7: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
^^^^^^
Gemfile:33:81: C: Line is too long. [136/80]
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:34:3: C: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem (str "puppet-module-posix-default-r") should appear before json.
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:34:81: C: Line is too long. [89/80]
gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby]
^^^^^^^^^
Gemfile:35:81: C: Line is too long. [89/80]
gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby]
^^^^^^^^^
Gemfile:36:81: C: Line is too long. [110/80]
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:36:83: C: Use %i or %I for an array of symbols.
gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:37:81: C: Line is too long. [110/80]
gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:37:83: C: Use %i or %I for an array of symbols.
gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:49:81: C: Line is too long. [92/80]
Gem::Requirement.new("< #{version}").satisfied_by?(Gem::Version.new(puppet_version.dup))
^^^^^^^^^^^^
Gemfile:115:3: C: Missing space after #.
# Hiera-eyaml is embedded in Hiera 5 / Puppet 5
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:115:4: C: Use only ascii symbols in comments.
# Hiera-eyaml is embedded in Hiera 5 / Puppet 5
^
Gemfile:120:1: C: Extra blank line detected.
Gemfile:128:34: C: Avoid comma after the last item of an array.
File.join(Dir.home, '.gemfile'),
^
Gemfile:133:5: C: The use of eval is a serious security risk.
eval(File.read(gemfile), binding)
^^^^
Gemfile:142:34: C: Trailing whitespace detected.
# Required puppetlabs_spec_helper
^
1 file inspected, 27 offenses detected
# diff of the two files (basically just some lines added which don't seem to be related to all the previous warnings
al@lab psick [development] $ diff Gemfile /tmp/sample/Gemfile
1,3d0
< # Based on pdk default Gemfile
< # Added danger gems
<
114,120d110
< if puppet_older_than?('5.0.0')
< # Hiera-eyaml is embedded in Hiera 5 / Puppet 5
< else
< gems['hiera-eyaml'] = ['~> 2.0']
< end
<
<
136,144d125
<
< # Danger integration: http://danger.systems
< gem 'danger'
< gem 'danger-changelog'
< gem 'danger-mention'
<
< # Required puppetlabs_spec_helper
< gem 'puppetlabs_spec_helper'
<
@alvagante
Copy link
Author

Just discovered that I hadn't the same .rubocop.yml in the two places :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment