Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix puppet-lint namespace clash with new puppetlabs-lint gem #170

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ruby:2.7-alpine

RUN mkdir /puppet-lint /puppet
RUN mkdir /puppetlabs-lint /puppet

VOLUME /puppet
WORKDIR /puppet
ENTRYPOINT ["/puppet-lint/bin/puppet-lint"]
ENTRYPOINT ["/puppetlabs-lint/bin/puppetlabs-lint"]
CMD ["--help"]

COPY . /puppet-lint/
COPY . /puppetlabs-lint/
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ This tool is only supported on Puppet 7 & 8 environments. In cases where Puppet
Install the Puppet Lint gem by running:

```
gem install puppet-lint
gem install puppetlabs-lint
```

## Testing with Puppet Lint

To test manifests for correct Puppet style, run the `puppet-lint` command with the path to the files you want to test.
To test manifests for correct Puppet style, run the `puppetlabs-lint` command with the path to the files you want to test.

For example:

```
puppet-lint ~/modules/puppetlabs-java/manifests/init.pp
puppetlabs-lint ~/modules/puppetlabs-java/manifests/init.pp
```

```
puppet-lint ~/modules/puppetlabs-mysql/manifests
puppetlabs-lint ~/modules/puppetlabs-mysql/manifests
```

### Fix issues automatically

To instruct Lint to automatically fix any issues that it detects, use the `--fix` flag:

```
puppet-lint --fix /modules
puppetlabs-lint --fix /modules
```

### Modify which checks to run
Expand All @@ -54,13 +54,13 @@ To list all available checks along with basic usage documentation, use the `--li
To run only specific checks, use the `--only-checks` option, with a comma-separated list of arguments specifying which checks to make:

```
puppet-lint --only-checks trailing_whitespace,140chars modules/
puppetlabs-lint --only-checks trailing_whitespace,140chars modules/
```

To avoid enormous patch sets when using the `--fix` flag, use the `--only-checks` option to limit which checks Puppet Lint makes:

```
puppet-lint --only-checks trailing_whitespace --fix modules/
puppetlabs-lint --only-checks trailing_whitespace --fix modules/
```

### Disable Lint checks
Expand All @@ -69,10 +69,10 @@ You can disable specific Lint checks on the command line, disable them permanent

#### Disable checks on the command line

To disable any of the checks when running the `puppet-lint` command, add a `--no-<check_name>-check` flag to the command. For example, to skip the 140-character check, run:
To disable any of the checks when running the `puppetlabs-lint` command, add a `--no-<check_name>-check` flag to the command. For example, to skip the 140-character check, run:

```
puppet-lint --no-140chars-check modules/
puppetlabs-lint --no-140chars-check modules/
```

#### Disable checks within Puppet code
Expand Down Expand Up @@ -123,7 +123,7 @@ Or to specify an allowlist of allowed checks, include a line like:
Please note that there is an important difference between reading options from the command line and reading options from a configuration file: In the former case the shell interprets one level of quotes. That does not happen in the latter case. So, it would make sense to quote some configuration values on the command line, like so:

```
$ puppet-lint --ignore-paths 'modules/stdlib/*' modules/
$ puppetlabs-lint --ignore-paths 'modules/stdlib/*' modules/
```

When reading from a configuration file those quotes would be passed on to the option parser -- probably not giving the expected result. Instead the line should read
Expand All @@ -134,7 +134,7 @@ When reading from a configuration file those quotes would be passed on to the op

## Testing with Puppet Lint as a Rake task

To test your entire Puppet manifest directory, add `require 'puppet-lint/tasks/puppet-lint'` to your Rakefile and then run:
To test your entire Puppet manifest directory, add `require 'puppetlabs/puppetlabs-lint/tasks/puppetlabs-lint'` to your Rakefile and then run:

```
rake lint
Expand All @@ -153,14 +153,14 @@ PuppetLint::RakeTask.new :lint do |config|
# List of checks to disable
config.disable_checks = ['documentation', '140chars']

# Should puppet-lint prefix it's output with the file being checked,
# Should puppetlabs-lint prefix it's output with the file being checked,
# defaults to true
config.with_filename = false

# Should the task fail if there were any warnings, defaults to false
config.fail_on_warnings = true

# Format string for puppet-lint's output (see the puppet-lint help output
# Format string for puppetlabs-lint's output (see the puppetlabs-lint help output
# for details
config.log_format = '%{filename} - %{message}'

Expand Down Expand Up @@ -239,7 +239,7 @@ validate lint check rubocop-Ruby 2.7.2-Puppet ~> 7:

## Options

See `puppet-lint --help` for a full list of command line options and checks.
See `puppetlabs-lint --help` for a full list of command line options and checks.

## Checks

Expand Down Expand Up @@ -309,7 +309,7 @@ If you have problems getting this tool up and running, please [contact Support](

## Thank you

Many thanks to the following people for contributing to puppet-lint
Many thanks to the following people for contributing to puppetlabs-lint

* James Turnbull (@kartar)
* Jan Vansteenkiste (@vStone)
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'bundler/gem_tasks'
require 'rubocop/rake_task'
require 'github_changelog_generator/task'
require 'puppet-lint/version'
require 'puppetlabs/puppetlabs-lint/version'
require 'rspec/core/rake_task'
require 'puppetlabs_spec_helper/tasks/fixtures'

Expand All @@ -13,7 +13,7 @@ else
GitHubChangelogGenerator::RakeTask.new(:changelog) do |config|
version = PuppetLint::VERSION
config.user = 'puppetlabs'
config.project = 'puppet-lint'
config.project = 'puppetlabs-lint'
config.since_tag = '2.5.0'
config.future_release = version.to_s
config.exclude_labels = %w[duplicate question invalid wontfix release-pr documentation]
Expand Down
2 changes: 1 addition & 1 deletion bin/puppet-lint → bin/puppetlabs-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'puppet-lint'
require 'puppetlabs/puppetlabs-lint'

exit PuppetLint::Bin.new(ARGV).run
20 changes: 10 additions & 10 deletions lib/puppet-lint.rb → lib/puppetlabs/puppetlabs-lint.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# rubocop:disable Naming/FileName

Check failure on line 1 in lib/puppetlabs/puppetlabs-lint.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7) / spec

Lint/MissingCopEnableDirective: Re-enable Naming/FileName cop with `# rubocop:enable` after disabling it.

Check failure on line 1 in lib/puppetlabs/puppetlabs-lint.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2) / spec

Lint/MissingCopEnableDirective: Re-enable Naming/FileName cop with `# rubocop:enable` after disabling it.

# encoding: utf-8

require 'set'
require 'json'
require 'puppet-lint/version'
require 'puppet-lint/lexer'
require 'puppet-lint/configuration'
require 'puppet-lint/data'
require 'puppet-lint/checks'
require 'puppet-lint/report/github'
require 'puppet-lint/bin'
require 'puppet-lint/monkeypatches'
require 'puppetlabs/puppetlabs-lint/version'
require 'puppetlabs/puppetlabs-lint/lexer'
require 'puppetlabs/puppetlabs-lint/configuration'
require 'puppetlabs/puppetlabs-lint/data'
require 'puppetlabs/puppetlabs-lint/checks'
require 'puppetlabs/puppetlabs-lint/report/github'
require 'puppetlabs/puppetlabs-lint/bin'
require 'puppetlabs/puppetlabs-lint/monkeypatches'

class PuppetLint::NoCodeError < StandardError; end

Expand All @@ -27,7 +27,7 @@
end
end

# Public: The public interface to puppet-lint.
# Public: The public interface to puppetlabs-lint.
class PuppetLint
# Public: Gets/Sets the String manifest code to be checked.
attr_accessor :code
Expand Down Expand Up @@ -263,4 +263,4 @@
# Default configuration options
PuppetLint.configuration.defaults

require 'puppet-lint/plugins'
require 'puppetlabs/puppetlabs-lint/plugins'
22 changes: 11 additions & 11 deletions lib/puppet-lint/bin.rb → lib/puppetlabs/puppetlabs-lint/bin.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'pathname'
require 'uri'
require 'puppet-lint/optparser'
require 'puppet-lint/report/codeclimate'
require 'puppetlabs/puppetlabs-lint/optparser'
require 'puppetlabs/puppetlabs-lint/report/codeclimate'

# Internal: The logic of the puppet-lint bin script, contained in a class for
# Internal: The logic of the puppetlabs-lint bin script, contained in a class for
# ease of testing.
class PuppetLint::Bin
# Public: Initialise a new PuppetLint::Bin.
Expand All @@ -18,21 +18,21 @@
@args = args
end

# Public: Run puppet-lint as a command line tool.
# Public: Run puppetlabs-lint as a command line tool.
#
# Returns an Integer exit code to be passed back to the shell.
def run
begin
opts = PuppetLint::OptParser.build(@args)
opts.parse!(@args)
rescue OptionParser::InvalidOption => e
puts "puppet-lint: #{e.message}"
puts "puppet-lint: try 'puppet-lint --help' for more information"
puts "puppetlabs-lint: #{e.message}"
puts "puppetlabs-lint: try 'puppetlabs-lint --help' for more information"
return 1
end

if PuppetLint.configuration.display_version
puts "puppet-lint #{PuppetLint::VERSION}"
puts "puppetlabs-lint #{PuppetLint::VERSION}"
return 0
end

Expand All @@ -42,8 +42,8 @@
end

if @args[0].nil?
puts 'puppet-lint: no file specified'
puts "puppet-lint: try 'puppet-lint --help' for more information"
puts 'puppetlabs-lint: no file specified'
puts "puppetlabs-lint: try 'puppetlabs-lint --help' for more information"
return 1
end

Expand All @@ -57,9 +57,9 @@
end

full_base_path_uri = if full_base_path.start_with?('/')
'file://' + full_base_path

Check failure on line 60 in lib/puppetlabs/puppetlabs-lint/bin.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7) / spec

Style/StringConcatenation: Prefer string interpolation to string concatenation. (https://rubystyle.guide#string-interpolation)

Check failure on line 60 in lib/puppetlabs/puppetlabs-lint/bin.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2) / spec

Style/StringConcatenation: Prefer string interpolation to string concatenation. (https://rubystyle.guide#string-interpolation)
else
'file:///' + full_base_path

Check failure on line 62 in lib/puppetlabs/puppetlabs-lint/bin.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7) / spec

Style/StringConcatenation: Prefer string interpolation to string concatenation. (https://rubystyle.guide#string-interpolation)

Check failure on line 62 in lib/puppetlabs/puppetlabs-lint/bin.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2) / spec

Style/StringConcatenation: Prefer string interpolation to string concatenation. (https://rubystyle.guide#string-interpolation)
end

full_base_path_uri += '/' unless full_base_path_uri.end_with?('/')
Expand Down Expand Up @@ -97,7 +97,7 @@
elsif PuppetLint.configuration.json
all_problems.each do |problems|
problems.each do |problem|
problem.delete_if { |key, _| [:description, :help_uri].include?(key) }

Check failure on line 100 in lib/puppetlabs/puppetlabs-lint/bin.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7) / spec

Performance/CollectionLiteralInLoop: Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant.

Check failure on line 100 in lib/puppetlabs/puppetlabs-lint/bin.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2) / spec

Performance/CollectionLiteralInLoop: Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant.
end
end
puts JSON.pretty_generate(all_problems)
Expand All @@ -107,8 +107,8 @@

return_val
rescue PuppetLint::NoCodeError
puts 'puppet-lint: no file specified or specified file does not exist'
puts "puppet-lint: try 'puppet-lint --help' for more information"
puts 'puppetlabs-lint: no file specified or specified file does not exist'
puts "puppetlabs-lint: try 'puppetlabs-lint --help' for more information"
1
end
end
Expand All @@ -134,7 +134,7 @@
new_rule = { 'id' => message[:check] }
new_rule['fullDescription'] = { 'text' => message[:description] } unless message[:description].nil?
new_rule['fullDescription'] = { 'text' => 'Check for any syntax error and record an error of each instance found.' } if new_rule['fullDescription'].nil? && message[:check] == :syntax
new_rule['defaultConfiguration'] = { 'level' => message[:KIND].downcase } if ['error', 'warning'].include?(message[:KIND].downcase)

Check failure on line 137 in lib/puppetlabs/puppetlabs-lint/bin.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7) / spec

Performance/CollectionLiteralInLoop: Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant.

Check failure on line 137 in lib/puppetlabs/puppetlabs-lint/bin.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2) / spec

Performance/CollectionLiteralInLoop: Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant.
new_rule['helpUri'] = message[:help_uri] unless message[:help_uri].nil?
rules << new_rule
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Public: A class that contains and provides information for the puppet-lint
# Public: A class that contains and provides information for the puppetlabs-lint
# checks.
#
# This class should not be used directly, but instead should be inherited.
Expand Down Expand Up @@ -146,7 +146,7 @@ def fullpath
end

# Public: Provides the path of the file being analysed as it was provided to
# puppet-lint to the check plugins.
# puppetlabs-lint to the check plugins.
#
# Returns the String path.
def path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'puppet-lint/checkplugin'
require 'puppetlabs/puppetlabs-lint/checkplugin'

# Internal: Various methods that orchestrate the actions of the puppet-lint
# Internal: Various methods that orchestrate the actions of the puppetlabs-lint
# check plugins.
class PuppetLint::Checks
# Public: Get an Array of problem Hashes.
Expand All @@ -13,7 +13,7 @@ def initialize

# Internal: Tokenise the manifest code and prepare it for checking.
#
# path - The path to the file as passed to puppet-lint as a String.
# path - The path to the file as passed to puppetlabs-lint as a String.
# content - The String manifest code to be checked.
#
# Returns nothing.
Expand Down Expand Up @@ -47,7 +47,7 @@ def load_data(path, content)

# Internal: Run the lint checks over the manifest code.
#
# fileinfo - The path to the file as passed to puppet-lint as a String.
# fileinfo - The path to the file as passed to puppetlabs-lint as a String.
# data - The String manifest code to be checked.
#
# Returns an Array of problem Hashes.
Expand Down Expand Up @@ -86,11 +86,11 @@ def run(fileinfo, data)
@problems
rescue StandardError => e
$stdout.puts <<-END.gsub(%r{^ {6}}, '')
Whoops! It looks like puppet-lint has encountered an error that it doesn't
know how to handle. Please open an issue at https://github.com/puppetlabs/puppet-lint
Whoops! It looks like puppetlabs-lint has encountered an error that it doesn't
know how to handle. Please open an issue at https://github.com/puppetlabs-lint
and paste the following output into the issue description.
---
puppet-lint version: #{PuppetLint::VERSION}
puppetlabs-lint version: #{PuppetLint::VERSION}
ruby version: #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}
platform: #{RUBY_PLATFORM}
file path: #{fileinfo}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Public: A singleton class to store the running configuration of
# puppet-lint.
# puppetlabs-lint.
class PuppetLint::Configuration
# Internal: Add helper methods for a new check to the
# PuppetLint::Configuration object.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'strscan'
require 'set'
require 'puppet-lint/lexer/token'
require 'puppet-lint/lexer/string_slurper'
require 'puppetlabs/puppetlabs-lint/lexer/token'
require 'puppetlabs/puppetlabs-lint/lexer/string_slurper'

# Internal: A generic error thrown by the lexer when it encounters something
# it can't handle.
Expand All @@ -20,7 +20,7 @@
# line_no - The Integer line number of the location of the error.
# column - The Integer column number of the location of the error.
# reason - A String describing the cause of the error (if known).
# rubocop:disable Lint/MissingSuper

Check failure on line 23 in lib/puppetlabs/puppetlabs-lint/lexer.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7) / spec

Lint/MissingCopEnableDirective: Re-enable Lint/MissingSuper cop with `# rubocop:enable` after disabling it.

Check failure on line 23 in lib/puppetlabs/puppetlabs-lint/lexer.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2) / spec

Lint/MissingCopEnableDirective: Re-enable Lint/MissingSuper cop with `# rubocop:enable` after disabling it.
def initialize(line_no, column, reason = nil)
@line_no = line_no
@column = column
Expand All @@ -32,7 +32,7 @@
end
end

# Internal: The puppet-lint lexer. Converts your manifest into its tokenised
# Internal: The puppetlabs-lint lexer. Converts your manifest into its tokenised
# form.
class PuppetLint::Lexer
def initialize
Expand Down
File renamed without changes.
Loading