From 9c5a11f36e603abe96a43d713ae41f8aae33483d Mon Sep 17 00:00:00 2001
From: Mantas Masalskis <mm@zammad.com>
Date: Fri, 1 Oct 2021 11:56:09 +0200
Subject: [PATCH] Maintenance: Rubocop uses custom inflections

---
 .rubocop/default.yml                                       | 2 ++
 Gemfile                                                    | 1 +
 Gemfile.lock                                               | 7 ++++++-
 config/initializers/inflections.rb                         | 2 +-
 .../20210923172256_issue_2619_kb_header_link_color.rb      | 2 +-
 spec/integration/github_spec.rb                            | 2 +-
 spec/integration/gitlab_spec.rb                            | 2 +-
 7 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/.rubocop/default.yml b/.rubocop/default.yml
index bf0656c06..f08267c10 100644
--- a/.rubocop/default.yml
+++ b/.rubocop/default.yml
@@ -6,6 +6,8 @@ require:
   - rubocop-performance
   - rubocop-rails
   - rubocop-rspec
+  - rubocop-inflector
+  - ../config/initializers/inflections.rb
   - ./rubocop_zammad.rb
 
 inherit_from:
diff --git a/Gemfile b/Gemfile
index 08c7be873..6ce41c930 100644
--- a/Gemfile
+++ b/Gemfile
@@ -198,6 +198,7 @@ group :development, :test do
   gem 'overcommit'
   gem 'rubocop'
   gem 'rubocop-faker'
+  gem 'rubocop-inflector'
   gem 'rubocop-performance'
   gem 'rubocop-rails'
   gem 'rubocop-rspec'
diff --git a/Gemfile.lock b/Gemfile.lock
index b9dbee417..f37b75ee5 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -512,6 +512,10 @@ GEM
     rubocop-faker (1.1.0)
       faker (>= 2.12.0)
       rubocop (>= 0.82.0)
+    rubocop-inflector (0.1.1)
+      activesupport
+      rubocop
+      rubocop-rspec
     rubocop-performance (1.11.5)
       rubocop (>= 1.7.0, < 2.0)
       rubocop-ast (>= 0.4.0)
@@ -729,6 +733,7 @@ DEPENDENCIES
   rszr (= 0.5.2)
   rubocop
   rubocop-faker
+  rubocop-inflector
   rubocop-performance
   rubocop-rails
   rubocop-rspec
@@ -762,4 +767,4 @@ RUBY VERSION
    ruby 2.7.4p191
 
 BUNDLED WITH
-   2.2.20
+   2.2.27
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index c73fe85db..8bfe2e324 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -21,7 +21,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
 
   # Rails thinks the singularized version of knowledge_bases is knowledge_basis?!
   # see: KnowledgeBase.table_name.singularize
-  inflect.singular(%r{(knowledge_base)s$}i, '\1')
+  inflect.irregular 'base', 'bases'
   inflect.acronym 'SMIME'
   inflect.acronym 'GitLab'
   inflect.acronym 'GitHub'
diff --git a/db/migrate/20210923172256_issue_2619_kb_header_link_color.rb b/db/migrate/20210923172256_issue_2619_kb_header_link_color.rb
index b2b39ea8b..53e0e680d 100644
--- a/db/migrate/20210923172256_issue_2619_kb_header_link_color.rb
+++ b/db/migrate/20210923172256_issue_2619_kb_header_link_color.rb
@@ -4,7 +4,7 @@ class Issue2619KbHeaderLinkColor < ActiveRecord::Migration[6.0]
   def up
     return if !Setting.exists?(name: 'system_init_done')
 
-    add_column :knowledge_bases, :color_header_link, :string, limit: 25, null: false, default: 'hsl(206,8%,50%)' # rubocop:disable Zammad/ExistsResetColumnInformation
+    add_column :knowledge_bases, :color_header_link, :string, limit: 25, null: false, default: 'hsl(206,8%,50%)'
     change_column_default :knowledge_bases, :color_header_link, nil
     KnowledgeBase.reset_column_information
   end
diff --git a/spec/integration/github_spec.rb b/spec/integration/github_spec.rb
index 1f38c81de..060009657 100644
--- a/spec/integration/github_spec.rb
+++ b/spec/integration/github_spec.rb
@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
 
 require 'rails_helper'
-RSpec.describe GitHub, type: :integration, required_envs: %w[GITHUB_ENDPOINT GITHUB_APITOKEN] do # rubocop:disable RSpec/FilePath
+RSpec.describe GitHub, type: :integration, required_envs: %w[GITHUB_ENDPOINT GITHUB_APITOKEN] do
 
   let(:instance) { described_class.new(ENV['GITHUB_ENDPOINT'], ENV['GITHUB_APITOKEN']) }
   let(:issue_data) do
diff --git a/spec/integration/gitlab_spec.rb b/spec/integration/gitlab_spec.rb
index 3810c78b3..788e376f6 100644
--- a/spec/integration/gitlab_spec.rb
+++ b/spec/integration/gitlab_spec.rb
@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
 
 require 'rails_helper'
-RSpec.describe GitLab, type: :integration, required_envs: %w[GITLAB_ENDPOINT GITLAB_APITOKEN] do # rubocop:disable RSpec/FilePath
+RSpec.describe GitLab, type: :integration, required_envs: %w[GITLAB_ENDPOINT GITLAB_APITOKEN] do
 
   let(:instance) { described_class.new(ENV['GITLAB_ENDPOINT'], ENV['GITLAB_APITOKEN']) }
   let(:issue_data) do
