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 rubocop Naming/MethodName violations #365

Open
gavindidrichsen opened this issue Sep 12, 2023 · 0 comments
Open

Fix rubocop Naming/MethodName violations #365

gavindidrichsen opened this issue Sep 12, 2023 · 0 comments
Labels

Comments

@gavindidrichsen
Copy link
Contributor

Describe the Bug

Rubocop recently began failing because of Naming/MethodName violations in 2 files:

  • lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb
  • lib/puppet-strings/yard/parsers/puppet/parser.rb

Since

  • running rubocop --auto-gen-config does 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 #364

Expected Behavior

Rubocop should not throw any exceptions

Steps to Reproduce

Steps to reproduce the behavior:

  1. Remove the rubocop:disable Naming/MethodName and rubocop:enable Naming/MethodName markers from the above files
  2. Re-run on the terminal bundle exec rubocop --format github and 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) ✗
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant