From 0a186e7f94dd80539bfca9ce3fc1812c2ca8eafb Mon Sep 17 00:00:00 2001
From: Darius Schneider <schneider@itc.rwth-aachen.de>
Date: Sun, 30 Mar 2025 22:31:29 +0200
Subject: [PATCH] cleanup

---
 rails/rubocop-for-gem.yml          | 170 +----------------------------
 rails/rubocop.yml                  | 163 +--------------------------
 rails/rubocop/rubocop-base.yml     |  74 +++++++++++--
 rails/rubocop/rubocop-minitest.yml |  19 ----
 rails/rubocop/rubocop-rails.yml    |  39 -------
 5 files changed, 68 insertions(+), 397 deletions(-)
 delete mode 100644 rails/rubocop/rubocop-minitest.yml
 delete mode 100644 rails/rubocop/rubocop-rails.yml

diff --git a/rails/rubocop-for-gem.yml b/rails/rubocop-for-gem.yml
index e124e5a..106faf8 100644
--- a/rails/rubocop-for-gem.yml
+++ b/rails/rubocop-for-gem.yml
@@ -1,17 +1,13 @@
+inherit_from: "https://git-ce.rwth-aachen.de/noc-public/noc-netze-gitlab-cicd/-/raw/main/rails/rubocop-base.yml"
+
 plugins:
-  - rubocop-minitest
   - rubocop-packaging
-  - rubocop-performance
-  - rubocop-rails
 
 # gem "rubocop", "1.74.0", require: false
 # gem "rubocop-minitest", "0.37.1", require: false
 # gem "rubocop-packaging", "0.6.0", require: false
 # gem "rubocop-performance", "1.24.0", require: false
 # gem "rubocop-rails", "2.30.3", require: false
-AllCops:
-  NewCops: enable # pending cops get enabled by default and must be disabled by hand, if needed
-
 
 # BEGIN Customizations
 # BEGIN Gemspec
@@ -20,169 +16,9 @@ Gemspec/RequireMFA:
   Enabled: false
 # END Gemspec
 
-# BEGIN Layout
-# align case with its 'end' to forbid deep indentation and be consistent with variable assignments
-Layout/CaseIndentation:
-  EnforcedStyle: end # default: case
-
-# only before, enforcing also after adds too many blank lines
-Layout/EmptyLinesAroundAccessModifier:
-  EnforcedStyle: only_before # default: around
-
-# prevent unnecessary deep indentation by enforcing 'end' to be at the start of the line
-Layout/EndAlignment:
-  EnforcedStyleAlignWith: start_of_line # default: keyword
-
-# indent first element one level deeper than the 'parent'
-Layout/FirstArrayElementIndentation:
-  EnforcedStyle: consistent # default: special_inside_parentheses
-
-# indent first element one level deeper than the 'parent'
-Layout/FirstHashElementIndentation:
-  EnforcedStyle: consistent # default: special_inside_parentheses
-
-# every screen should be able to handle 150 characters
-Layout/LineLength:
-  Max: 150 # default: 120
-
-# indent each method call one level deeper than the 'parent'
-Layout/MultilineMethodCallIndentation:
-  EnforcedStyle: indented # default: aligned
-# END Layout
-
-
-# BEGIN Metrics
-# too restrictive, this kind of high complexity is needed at times
-Metrics/AbcSize:
-  Enabled: false
-
-# default is too restrictive, however, having some restriction incentivizes to use helper methods
-Metrics/BlockLength:
-  AllowedMethods: ['class_eval', 'module_eval', 'refine'] # default: 'refine'
-  CountAsOne: &array_hash_heredoc_method_call ['array', 'hash', 'heredoc', 'method_call'] # default: []
-  Exclude: &test_config_db_gemspec_subconfig ['test/**/*', 'config/**/*', 'db/**/*', '*.gemspec', '**/*/*config.rb']
-
-# default is too restrictive, having some restriction incentivizes to split up overly large classes
-Metrics/ClassLength:
-  CountAsOne: *array_hash_heredoc_method_call # default: []
-  Max: 300 # default: 100
-  Exclude: *test_config_db_gemspec_subconfig
-
-# default is too restrictive, allow higher complexity
-Metrics/CyclomaticComplexity:
-  Max: 14 # default: 7
-
-# default is too restrictive, allow longer methods
-Metrics/MethodLength:
-  CountAsOne: *array_hash_heredoc_method_call # default: []
-  Max: 30 # default: 10
-  Exclude: *test_config_db_gemspec_subconfig
-
-# default is too restrictive, allow longer modules
-Metrics/ModuleLength:
-  CountAsOne: *array_hash_heredoc_method_call # default: []
-  Max: 300 # default: 100
-  Exclude: *test_config_db_gemspec_subconfig
-
-# long parameter lists add too much complexity, keyword args are named and thus more obvious what is expected, ignore them
-Metrics/ParameterLists:
-  CountKeywordArgs: false # default: true
-
-# default is too restrictive, allow higher complexity
-Metrics/PerceivedComplexity:
-  Max: 16 # default: 8
-# END Metrics
-
-
-# BEGIN Minitest
-# seems kind of buggy, when a custom message is given, this is flagged
-Minitest/AssertWithExpectedArgument:
-  Enabled: false
-
-# allow more assertions than default, but also not too many
-Minitest/MultipleAssertions:
-  Max: 8 # default: 3
-# END Minitest
-
-
 # BEGIN Naming
 # the default gem module must be named like the gem, so allow dashes
 Naming/FileName:
   Exclude: ['lib/*.rb']
 # END Naming
-
-
-# BEGIN Rails
-# file paths should be built with arguments instead of a single string
-Rails/ApplicationController:
-  Exclude: ['app/controllers/api/**/*', 'app/controllers/a_p_i/**/*'] # exclude API namespace, but not others (convention)
-
-# exclude migrations since non-ApplicationRecord behavior might be desired
-Rails/ApplicationRecord:
-  Exclude: ['db/migrate/*']
-
-# ensure paths are built using a filesystem agnostic way, i.e. arguments instead of a single string
-Rails/FilePath:
-  EnforcedStyle: arguments # default: slashes
-
-# no reason not to use an established Rails feature if developers see fit
-Rails/HasAndBelongsToMany:
-  Enabled: false
-
-# prevent puts, but exclude test, config, db since Rails Logger may not have been loaded
-Rails/Output:
-  Exclude: ['test/**/*', 'config/**/*', 'db/**/*']
-
-# allow usage of methods that skip validations; we trust developers know what they are doing
-Rails/SkipsModelValidations:
-  Enabled: false
-
-# allow usage of three-state boolean columns, it may be an STI table
-Rails/ThreeStateBooleanColumn:
-  Enabled: false
-# END Rails
-
-
-# BEGIN Style
-# allow compact style for gems that contain app directory for rails integration
-Style/ClassAndModuleChildren:
-  Exclude: ['app/**/*']
-
-# documentation of classes in migrations and tests is not needed
-Style/Documentation:
-  Exclude: *test_config_db_gemspec_subconfig
-
-# allow in auto-generated files
-Style/GlobalStdStream:
-  Exclude: *test_config_db_gemspec_subconfig
-
-# allow empty parentheses to differentiate method calls vs attributes
-Style/MethodCallWithoutArgsParentheses:
-  Enabled: false
-
-# explicit returns are nice and convey meaning, so allow them
-Style/RedundantReturn:
-  Enabled: false
-
-# allow for explicit calls to self to help differentiate between method calls vs local variables
-Style/RedundantSelf:
-  Enabled: false
-
-# enforce double quotes in string literals
-Style/StringLiterals:
-  EnforcedStyle: double_quotes # default: single_quotes
-
-# enforce double quotes inside string interpolations
-Style/StringLiteralsInInterpolation:
-  EnforcedStyle: double_quotes # default: single_quotes
-
-# allow only brackets, not %i or %I
-Style/SymbolArray:
-  EnforcedStyle: brackets # default: percent
-  MinSize: 1 # default: 2
-
-# allow only brackets, not %w or %W
-Style/WordArray:
-  EnforcedStyle: brackets # default: percent
-  MinSize: 1 # default: 2
-# END Style
+# END Customizations
diff --git a/rails/rubocop.yml b/rails/rubocop.yml
index 4521098..5dae786 100644
--- a/rails/rubocop.yml
+++ b/rails/rubocop.yml
@@ -1,176 +1,19 @@
+inherit_from: "https://git-ce.rwth-aachen.de/noc-public/noc-netze-gitlab-cicd/-/raw/main/rails/rubocop/rubocop-base.yml"
+
 plugins:
   - rubocop-capybara
-  - rubocop-minitest
-  - rubocop-performance
-  - rubocop-rails
 
 # gem "rubocop", "1.74.0", require: false
 # gem "rubocop-capybara", "2.22.1", require: false
 # gem "rubocop-minitest", "0.37.1", require: false
 # gem "rubocop-performance", "1.24.0", require: false
 # gem "rubocop-rails", "2.30.3", require: false
-AllCops:
-  NewCops: enable # pending cops get enabled by default and must be disabled by hand, if needed
-
 
 # BEGIN Customizations
-# BEGIN Layout
-# align case with its 'end' to forbid deep indentation and be consistent with variable assignments
-Layout/CaseIndentation:
-  EnforcedStyle: end # default: case
-
-# only before, enforcing also after adds too many blank lines
-Layout/EmptyLinesAroundAccessModifier:
-  EnforcedStyle: only_before # default: around
-
-# prevent unnecessary deep indentation by enforcing 'end' to be at the start of the line
-Layout/EndAlignment:
-  EnforcedStyleAlignWith: start_of_line # default: keyword
-
-# indent first element one level deeper than the 'parent'
-Layout/FirstArrayElementIndentation:
-  EnforcedStyle: consistent # default: special_inside_parentheses
-
-# indent first element one level deeper than the 'parent'
-Layout/FirstHashElementIndentation:
-  EnforcedStyle: consistent # default: special_inside_parentheses
-
-# every screen should be able to handle 150 characters
-Layout/LineLength:
-  Max: 150 # default: 120
-
-# indent each method call one level deeper than the 'parent'
-Layout/MultilineMethodCallIndentation:
-  EnforcedStyle: indented # default: aligned
-# END Layout
-
-
-# BEGIN Metrics
-# too restrictive, this kind of high complexity is needed at times
-Metrics/AbcSize:
-  Enabled: false
-
-# default is too restrictive, however, having some restriction incentivizes to use helper methods
-Metrics/BlockLength:
-  AllowedMethods: ['class_eval', 'module_eval', 'refine'] # default: 'refine'
-  CountAsOne: &array_hash_heredoc_method_call ['array', 'hash', 'heredoc', 'method_call'] # default: []
-  Exclude: &test_config_db ['test/**/*', 'config/**/*', 'db/**/*']
-
-# default is too restrictive, having some restriction incentivizes to split up overly large classes
-Metrics/ClassLength:
-  CountAsOne: *array_hash_heredoc_method_call # default: []
-  Max: 300 # default: 100
-  Exclude: *test_config_db
-
-# default is too restrictive, allow higher complexity
-Metrics/CyclomaticComplexity:
-  Max: 14 # default: 7
-
-# default is too restrictive, allow longer methods
-Metrics/MethodLength:
-  CountAsOne: *array_hash_heredoc_method_call # default: []
-  Max: 30 # default: 10
-  Exclude: *test_config_db
-
-# default is too restrictive, allow longer modules
-Metrics/ModuleLength:
-  CountAsOne: *array_hash_heredoc_method_call # default: []
-  Max: 300 # default: 100
-  Exclude: *test_config_db
-
-# long parameter lists add too much complexity, keyword args are named and thus more obvious what is expected, ignore them
-Metrics/ParameterLists:
-  CountKeywordArgs: false # default: true
-
-# default is too restrictive, allow higher complexity
-Metrics/PerceivedComplexity:
-  Max: 16 # default: 8
-# END Metrics
-
-
-# BEGIN Minitest
-# seems kind of buggy, when a custom message is given, this is flagged
-Minitest/AssertWithExpectedArgument:
-  Enabled: false
-
-# allow more assertions than default, but also not too many
-Minitest/MultipleAssertions:
-  Max: 8 # default: 3
-# END Minitest
-
-
-# BEGIN Rails
-# file paths should be built with arguments instead of a single string
-Rails/ApplicationController:
-  Exclude: ['app/controllers/api/**/*', 'app/controllers/a_p_i/**/*'] # exclude API namespace, but not others (convention)
-
-# exclude migrations since non-ApplicationRecord behavior might be desired
-Rails/ApplicationRecord:
-  Exclude: ['db/migrate/*']
-
-# ensure paths are built using a filesystem agnostic way, i.e. arguments instead of a single string
-Rails/FilePath:
-  EnforcedStyle: arguments # default: slashes
-
-# no reason not to use an established Rails feature if developers see fit
-Rails/HasAndBelongsToMany:
-  Enabled: false
-
-# prevent puts, but exclude test, config, db since Rails Logger may not have been loaded
-Rails/Output:
-  Exclude: ['test/**/*', 'config/**/*', 'db/**/*']
-
-# allow usage of methods that skip validations; we trust developers know what they are doing
-Rails/SkipsModelValidations:
-  Enabled: false
-
-# allow usage of three-state boolean columns, it may be an STI table
-Rails/ThreeStateBooleanColumn:
-  Enabled: false
-# END Rails
-
-
 # BEGIN Style
 # prefer compact style, since Zeitwerk handles initialization of modules
 Style/ClassAndModuleChildren:
   EnforcedStyle: compact # default: nested
   Exclude: ['config/application.rb']
-
-# documentation of classes in migrations and tests is not needed
-Style/Documentation:
-  Exclude: *test_config_db
-
-# allow in auto-generated files
-Style/GlobalStdStream:
-  Exclude: *test_config_db
-
-# allow empty parentheses to differentiate method calls vs attributes
-Style/MethodCallWithoutArgsParentheses:
-  Enabled: false
-
-# explicit returns are nice and convey meaning, so allow them
-Style/RedundantReturn:
-  Enabled: false
-
-# allow for explicit calls to self to help differentiate between method calls vs local variables
-Style/RedundantSelf:
-  Enabled: false
-
-# enforce double quotes in string literals
-Style/StringLiterals:
-  EnforcedStyle: double_quotes # default: single_quotes
-
-# enforce double quotes inside string interpolations
-Style/StringLiteralsInInterpolation:
-  EnforcedStyle: double_quotes # default: single_quotes
-
-# allow only brackets, not %i or %I
-Style/SymbolArray:
-  EnforcedStyle: brackets # default: percent
-  MinSize: 1 # default: 2
-
-# allow only brackets, not %w or %W
-Style/WordArray:
-  EnforcedStyle: brackets # default: percent
-  MinSize: 1 # default: 2
 # END Style
+# END Customizations
diff --git a/rails/rubocop/rubocop-base.yml b/rails/rubocop/rubocop-base.yml
index a007554..371266a 100644
--- a/rails/rubocop/rubocop-base.yml
+++ b/rails/rubocop/rubocop-base.yml
@@ -1,8 +1,12 @@
 plugins:
+  - rubocop-minitest
   - rubocop-performance
+  - rubocop-rails
 
-# gem 'rubocop', '1.73.2', require: false
-# gem 'rubocop-performance', '1.24.0', require: false
+# gem "rubocop", "1.74.0", require: false
+# gem "rubocop-minitest", "0.37.1", require: false
+# gem "rubocop-performance", "1.24.0", require: false
+# gem "rubocop-rails", "2.30.3", require: false
 AllCops:
   NewCops: enable # pending cops get enabled by default and must be disabled by hand, if needed
 
@@ -48,13 +52,13 @@ Metrics/AbcSize:
 Metrics/BlockLength:
   AllowedMethods: ['class_eval', 'module_eval', 'refine'] # default: 'refine'
   CountAsOne: &array_hash_heredoc_method_call ['array', 'hash', 'heredoc', 'method_call'] # default: []
-  Exclude: &test_config_db ['test/**/*', 'config/**/*', 'db/**/*']
+  Exclude: &test_config_db_gemspec_subconfig ['test/**/*', 'config/**/*', 'db/**/*', '*.gemspec', '**/*/*config.rb']
 
 # default is too restrictive, having some restriction incentivizes to split up overly large classes
 Metrics/ClassLength:
   CountAsOne: *array_hash_heredoc_method_call # default: []
   Max: 300 # default: 100
-  Exclude: *test_config_db
+  Exclude: *test_config_db_gemspec_subconfig
 
 # default is too restrictive, allow higher complexity
 Metrics/CyclomaticComplexity:
@@ -64,13 +68,13 @@ Metrics/CyclomaticComplexity:
 Metrics/MethodLength:
   CountAsOne: *array_hash_heredoc_method_call # default: []
   Max: 30 # default: 10
-  Exclude: *test_config_db
+  Exclude: *test_config_db_gemspec_subconfig
 
 # default is too restrictive, allow longer modules
 Metrics/ModuleLength:
   CountAsOne: *array_hash_heredoc_method_call # default: []
   Max: 300 # default: 100
-  Exclude: *test_config_db
+  Exclude: *test_config_db_gemspec_subconfig
 
 # long parameter lists add too much complexity, keyword args are named and thus more obvious what is expected, ignore them
 Metrics/ParameterLists:
@@ -82,19 +86,64 @@ Metrics/PerceivedComplexity:
 # END Metrics
 
 
+# BEGIN Minitest
+# seems kind of buggy, when a custom message is given, this is flagged
+Minitest/AssertWithExpectedArgument:
+  Enabled: false
+
+# allow more assertions than default, but also not too many
+Minitest/MultipleAssertions:
+  Max: 8 # default: 3
+# END Minitest
+
+
+# BEGIN Rails
+# exclude API namespace, but not others (ITC convention)
+Rails/ApplicationController:
+  Exclude: ['app/controllers/api/**/*', 'app/controllers/a_p_i/**/*']
+
+# exclude migrations since non-ApplicationRecord behavior might be desired
+Rails/ApplicationRecord:
+  Exclude: ['db/migrate/*']
+
+# ensure paths are built using a filesystem agnostic way, i.e. arguments instead of a single string
+Rails/FilePath:
+  EnforcedStyle: arguments # default: slashes
+
+# no reason not to use an established Rails feature if developers see fit
+Rails/HasAndBelongsToMany:
+  Enabled: false
+
+# prevent puts, but exclude test, config, db since Rails Logger may not have been loaded
+Rails/Output:
+  Exclude: *test_config_db_gemspec_subconfig
+
+# allow usage of methods that skip validations; we trust developers know what they are doing
+Rails/SkipsModelValidations:
+  Enabled: false
+# END Rails
+
+
 # BEGIN Style
-# prefer compact style, since Zeitwerk handles initialization of modules
-Style/ClassAndModuleChildren:
-  EnforcedStyle: compact # default: nested
-  Exclude: ['config/application.rb']
+# prevent getting around most cops, but allow a few that may be impossible to resolve otherwise, f.e.:
+# Lint/UnusedMethodArgument: subclasses that are passed unused keyword args, but not using them must be allowed
+# Naming/PredicateName: allow DSL style methods like Rails 'has_one'
+# Naming/VariableNumber: allow passing keyword args to other libraries that violate naming conventions
+# Rails/CreateTableWithTimestamps: audited does not include 'updated_at', may also be true for other libraries, ultimately leave the choice to end-user
+# Rails/DangerousColumnNames: mainly to allow adding and changing column named 'id'
+# Rails/NegateInclude: allow classes to define include? and not force to also define exclude?, like IPAddr
+# Rails/ThreeStateBooleanColumn: allow usage of three-state boolean columns, it may be an STI table
+Style/DisableCopsWithinSourceCodeDirective:
+  Enabled: true
+  AllowedCops: ['Lint/UnusedMethodArgument', 'Naming/PredicateName', 'Naming/VariableNumber', 'Rails/CreateTableWithTimestamps', 'Rails/DangerousColumnNames', 'Rails/NegateInclude', 'Rails/ThreeStateBooleanColumn']
 
 # documentation of classes in migrations and tests is not needed
 Style/Documentation:
-  Exclude: *test_config_db
+  Exclude: *test_config_db_gemspec_subconfig
 
 # allow in auto-generated files
 Style/GlobalStdStream:
-  Exclude: *test_config_db
+  Exclude: *test_config_db_gemspec_subconfig
 
 # allow empty parentheses to differentiate method calls vs attributes
 Style/MethodCallWithoutArgsParentheses:
@@ -126,3 +175,4 @@ Style/WordArray:
   EnforcedStyle: brackets # default: percent
   MinSize: 1 # default: 2
 # END Style
+# END Customizations
diff --git a/rails/rubocop/rubocop-minitest.yml b/rails/rubocop/rubocop-minitest.yml
deleted file mode 100644
index a6f453f..0000000
--- a/rails/rubocop/rubocop-minitest.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-plugins:
-  - rubocop-minitest
-
-# gem 'rubocop', '1.73.2', require: false
-# gem 'rubocop-minitest', '0.37.1', require: false
-AllCops:
-  NewCops: enable # pending cops get enabled by default and must be disabled by hand, if needed
-
-
-# BEGIN Customizations
-# BEGIN Minitest
-# seems kind of buggy, when a custom message is given, this is flagged
-Minitest/AssertWithExpectedArgument:
-  Enabled: false
-
-# allow more assertions than default, but also not too many
-Minitest/MultipleAssertions:
-  Max: 8 # default: 3
-# END Minitest
diff --git a/rails/rubocop/rubocop-rails.yml b/rails/rubocop/rubocop-rails.yml
deleted file mode 100644
index 391bfb2..0000000
--- a/rails/rubocop/rubocop-rails.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-plugins:
-  - rubocop-rails
-
-# gem 'rubocop', '1.73.2', require: false
-# gem 'rubocop-rails', '2.30.3', require: false
-AllCops:
-  NewCops: enable # pending cops get enabled by default and must be disabled by hand, if needed
-
-
-# BEGIN Customizations
-# BEGIN Rails
-# file paths should be built with arguments instead of a single string
-Rails/ApplicationController:
-  Exclude: ['app/controllers/api/**/*', 'app/controllers/a_p_i/**/*'] # exclude API namespace, but not others (ITC convention)
-
-# exclude migrations since non-ApplicationRecord behavior might be desired
-Rails/ApplicationRecord:
-  Exclude: ['db/migrate/*']
-
-# ensure paths are built using a filesystem agnostic way, i.e. arguments instead of a single string
-Rails/FilePath:
-  EnforcedStyle: arguments # default: slashes
-
-# no reason not to use an established Rails feature if developers see fit
-Rails/HasAndBelongsToMany:
-  Enabled: false
-
-# prevent puts, but exclude test, config, db since Rails Logger may not have been loaded
-Rails/Output:
-  Exclude: ['test/**/*', 'config/**/*', 'db/**/*']
-
-# allow usage of methods that skip validations; we trust developers know what they are doing
-Rails/SkipsModelValidations:
-  Enabled: false
-
-# allow usage of three-state boolean columns, it may be an STI table
-Rails/ThreeStateBooleanColumn:
-  Enabled: false
-# END Rails
-- 
GitLab