puppetlabs / puppetlabs/puppet-strings
Fix rubocop ``Naming/MethodName`` violations
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 90
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Describe the Bug
Rubocop recently began failing because of Naming/MethodName violations in 2 files:
lib/puppet-strings/yard/handlers/ruby/data_type_handler.rblib/puppet-strings/yard/parsers/puppet/parser.rb
Since
- running
rubocop --auto-gen-configdoes not (at this time) add these violations to the.rubocop_todo.yml; and - adjusting these methods may have a downstream impact; and
- CI needs to be made green but not without recording a TODO to fix the violations
Then it was decided to explicitly
- add a #TODO to the files and a
rubocop:disable Naming/MethodName; and - raise this issue to record the requirement.
See PR https://github.com/puppetlabs/puppet-strings/pull/364
Expected Behavior
Rubocop should not throw any exceptions
Steps to Reproduce
Steps to reproduce the behavior:
- Remove the
rubocop:disable Naming/MethodNameandrubocop:enable Naming/MethodNamemarkers from the above files - Re-run on the terminal
bundle exec rubocop --format githuband note the exceptions as listed at the end of this issue.
Environment
- Version [e.g. 1.27.0]
- Platform [e.g. Ubuntu 18.04]
Additional Context
See below the output from rubocop and the diff showing the rubocop disable commands:
➜ puppet-strings git:(cat-1404-fix_rubocop_nightly_failures) ✗ bundle exec rubocop --format github
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=147,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=151,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=156,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=162,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=166,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=170,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=174,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=178,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=182,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=186,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=190,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=194,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=198,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=202,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=208,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb,line=212,col=9::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/parsers/puppet/parser.rb,line=43,col=7::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/parsers/puppet/parser.rb,line=49,col=7::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/parsers/puppet/parser.rb,line=53,col=7::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/parsers/puppet/parser.rb,line=59,col=7::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/parsers/puppet/parser.rb,line=65,col=7::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/parsers/puppet/parser.rb,line=71,col=7::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/parsers/puppet/parser.rb,line=77,col=7::Naming/MethodName: Use snake_case for method names.
::error file=lib/puppet-strings/yard/parsers/puppet/parser.rb,line=83,col=7::Naming/MethodName: Use snake_case for method names.
➜ puppet-strings git:(cat-1404-fix_rubocop_nightly_failures) ✗ code lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb
➜ puppet-strings git:(cat-1404-fix_rubocop_nightly_failures) ✗ git diff
diff --git a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb
index 7268d46..20c8569 100644
--- a/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb
+++ b/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb
@@ -143,6 +143,8 @@ class PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler < PuppetStrings::Yard
@literal_visitor.visit_this_0(self, ast)
end
+ # TODO: Fix the rubocop violations in this file between the following rubocop:disable/enable lines
+ # rubocop:disable Naming/MethodName
# ----- The following methods are different/additions from the original Literal_evaluator
def literal_Object(o)
# Ignore any other object types
@@ -214,6 +216,7 @@ class PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler < PuppetStrings::Yard
result[literal(entry.key)] = literal(entry.value)
end
end
+ # rubocop:enable Naming/MethodName
end
# Extracts the datatype attributes from a Puppet Data Type interface hash.
diff --git a/lib/puppet-strings/yard/parsers/puppet/parser.rb b/lib/puppet-strings/yard/parsers/puppet/parser.rb
index 98f4e30..7d227bf 100644
--- a/lib/puppet-strings/yard/parsers/puppet/parser.rb
+++ b/lib/puppet-strings/yard/parsers/puppet/parser.rb
@@ -40,6 +40,8 @@ class PuppetStrings::Yard::Parsers::Puppet::Parser < YARD::Parser::Base
private
+ # TODO: Fix the rubocop violations in this file between the following rubocop:disable/enable lines
+ # rubocop:disable Naming/MethodName
def transform_Program(o)
# Cache the lines of the source text; we'll use this to locate comments
@lines = o.source_text.lines.to_a
@@ -83,4 +85,5 @@ class PuppetStrings::Yard::Parsers::Puppet::Parser < YARD::Parser::Base
def transform_Object(o)
# Ignore anything else (will be compacted out of the resulting array)
end
+ # rubocop:enable Naming/MethodName
end
➜ puppet-strings git:(cat-1404-fix_rubocop_nightly_failures) ✗
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb and lib/puppet-strings/yard/parsers/puppet/parser.rb, reviewing the methods reported by Naming/MethodName and their downstream impact. Run bundle exec rubocop --format github after removing the disable markers. Done means the reported violations are resolved and RuboCop completes without exceptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100