diff --git a/.coffeelint/rules/prevent_underscore_backport.coffee b/.coffeelint/rules/prevent_underscore_backport.coffee new file mode 100644 index 000000000..d87fc2b79 --- /dev/null +++ b/.coffeelint/rules/prevent_underscore_backport.coffee @@ -0,0 +1,20 @@ +module.exports = class PreventUnderscoreBackport + + rule: + name: 'prevent_underscore_backport' + level: 'error' + message: 'The method __(...) is not available in current stable' + description: ''' + ''' + + constructor: -> + @callTokens = [] + + tokens: ['CALL_START'] + + lintToken: (token, tokenApi) -> + [type, tokenValue] = token + + p = tokenApi.peek(-1) + if p[1] == '__' + return { } diff --git a/.gitlab/ci/pre.yml b/.gitlab/ci/pre.yml index 5a6d2a651..fab758dce 100644 --- a/.gitlab/ci/pre.yml +++ b/.gitlab/ci/pre.yml @@ -48,7 +48,7 @@ brakeman: coffeelint: <<: *template_pre script: - - coffeelint app/ + - coffeelint --rules ./.coffeelint/rules/* app/ bundle-audit: <<: *template_pre diff --git a/.rubocop/cop/zammad/prevent_underscore_backport.rb b/.rubocop/cop/zammad/prevent_underscore_backport.rb new file mode 100644 index 000000000..7bb6791a3 --- /dev/null +++ b/.rubocop/cop/zammad/prevent_underscore_backport.rb @@ -0,0 +1,17 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +module RuboCop + module Cop + module Zammad + class PreventUnderscroreBackport < Base + MSG = <<~ERROR_MESSAGE.freeze + The method __(...) is not available in current stable. + ERROR_MESSAGE + + def on_send(node) + add_offense(node) if node.method_name.eql? :__ + end + end + end + end +end diff --git a/.rubocop/rubocop_zammad.rb b/.rubocop/rubocop_zammad.rb index f3e8764cd..04ff86a9c 100644 --- a/.rubocop/rubocop_zammad.rb +++ b/.rubocop/rubocop_zammad.rb @@ -10,3 +10,4 @@ require_relative 'cop/zammad/no_to_sym_on_string' require_relative 'cop/zammad/prefer_negated_if_over_unless' require_relative 'cop/zammad/update_copyright' require_relative 'cop/zammad/forbid_rand' +require_relative 'cop/zammad/prevent_underscore_backport' diff --git a/coffeelint.json b/coffeelint.json index 548e8e3e5..ca49e3c31 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -131,5 +131,8 @@ }, "transform_messes_up_line_numbers": { "level": "error" + }, + "prevent_underscore_backport": { + "level": "error" } }