diff --git a/.rubocop.yml b/.rubocop.yml index 1ab77533c..6010a7d4c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,7 @@ require: - rubocop/rspec/focused - ./lib/cops/unscoped.rb + - ./lib/cops/application_name.rb inherit_gem: rubocop-rails_config: - config/rails.yml @@ -12,6 +13,17 @@ AllCops: - "bin/*" - "node_modules/**/*" +DS/Unscoped: + Enabled: true + +DS/ApplicationName: + Enabled: true + Exclude: + - './config/application_name.rb' + - './lib/cops/application_name.rb' + - './lib/linters/application_name_linter.rb' + - "./spec/**/*" + Bundler/DuplicatedGem: Enabled: true diff --git a/lib/cops/application_name.rb b/lib/cops/application_name.rb new file mode 100644 index 000000000..402a041ec --- /dev/null +++ b/lib/cops/application_name.rb @@ -0,0 +1,17 @@ +if defined?(RuboCop) + module RuboCop + module Cop + module DS + class ApplicationName < Cop + MSG = "Avoid hardcoding `demarches-simplifiees.fr`. Instead use a dedicated environnement variable." + + def on_str(node) + return unless node.source.include?('demarches-simplifiees.fr') + + add_offense(node) + end + end + end + end + end +end