puppetlabs / puppet-strings

The next generation Puppet documentation extraction and presentation tool.
http://puppetlabs.github.io/puppet-strings/
Apache License 2.0
90 stars 84 forks source link

Fix rubocop ``Naming/MethodName`` violations #365

Open gavindidrichsen opened 1 year ago

gavindidrichsen commented 1 year ago

Describe the Bug

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

Since

Then it was decided to explicitly

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:

  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

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) ✗