Sha256: ba8cd035937a5fc0d58233b78e5c648e65ab106eb6055504aa7725f6f75cf7b0
Contents?: true
Size: 719 Bytes
Versions: 10
Compression:
Stored size: 719 Bytes
Contents
# frozen_string_literal: true module Gitlab module Styles module Common module BannedConstants attr_reader :replacements, :message_template, :autocorrect def on_const(node) constant = node.source.delete_prefix('::') return unless replacements.key?(constant) replacement = replacements.fetch(constant) message = format(message_template, { replacement: replacement }) add_offense(node, message: message) do |corrector| next unless autocorrect replacement = "::#{replacement}" if node.source.start_with?("::") corrector.replace(node, replacement) end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems