Commit 3a884228 authored by Thong Kuah's avatar Thong Kuah 💬
Browse files

Address ConstGetInheritFalse violations

There should be no cases where we need to inherit=true.
parent b07eeb8c
......@@ -8,13 +8,13 @@ module Clusters
included do
state_machine :status do
before_transition any => [:installed, :updated] do |application|
application.version = application.class.const_get(:VERSION)
application.version = application.class.const_get(:VERSION, false)
end
end
end
 
def update_available?
version != self.class.const_get(:VERSION)
version != self.class.const_get(:VERSION, false)
end
end
end
......
......@@ -44,7 +44,7 @@ module PrometheusAdapter
end
 
def query_klass_for(query_name)
Gitlab::Prometheus::Queries.const_get("#{query_name.to_s.classify}Query")
Gitlab::Prometheus::Queries.const_get("#{query_name.to_s.classify}Query", false)
end
 
def build_query_args(*args)
......
......@@ -24,7 +24,7 @@ class Note < ApplicationRecord
 
class << self
def values
constants.map {|const| self.const_get(const)}
constants.map {|const| self.const_get(const, false)}
end
 
def value?(val)
......
......@@ -138,7 +138,7 @@ class Upload < ApplicationRecord
end
 
def uploader_class
Object.const_get(uploader)
Object.const_get(uploader, false)
end
 
def identifier
......
......@@ -34,6 +34,7 @@ module Fog
# Gems that have not yet updated with the new fog-core namespace
LEGACY_FOG_PROVIDERS = %w(google rackspace aliyun).freeze
 
# rubocop:disable Cop/ConstGetInheritFalse
def service_provider_constant(service_name, provider_name)
args = service_provider_search_args(service_name, provider_name)
Fog.const_get(args.first).const_get(*const_get_args(args.second))
......@@ -48,5 +49,6 @@ module Fog
[provider_name, service_name]
end
end
# rubocop:enable Cop/ConstGetInheritFalse
end
end
......@@ -13,7 +13,7 @@ def instrument_classes(instrumentation)
instrumentation.instrument_methods(Gitlab::Git)
 
Gitlab::Git.constants.each do |name|
const = Gitlab::Git.const_get(name)
const = Gitlab::Git.const_get(name, false)
 
next unless const.is_a?(Module)
 
......@@ -75,7 +75,7 @@ def instrument_classes(instrumentation)
instrumentation.instrument_instance_methods(Rouge::Formatters::HTMLGitlab)
 
[:XML, :HTML].each do |namespace|
namespace_mod = Nokogiri.const_get(namespace)
namespace_mod = Nokogiri.const_get(namespace, false)
 
instrumentation.instrument_methods(namespace_mod)
instrumentation.instrument_methods(namespace_mod::Document)
......
......@@ -104,10 +104,10 @@ class Settings < Settingslogic
 
# check that `current` (string or integer) is a contant in `modul`.
def verify_constant(modul, current, default)
constant = modul.constants.find { |name| modul.const_get(name) == current }
value = constant.nil? ? default : modul.const_get(constant)
constant = modul.constants.find { |name| modul.const_get(name, false) == current }
value = constant.nil? ? default : modul.const_get(constant, false)
if current.is_a? String
value = modul.const_get(current.upcase) rescue default
value = modul.const_get(current.upcase, false) rescue default
end
 
value
......
......@@ -80,7 +80,7 @@ module API
note = create_note(noteable, opts)
 
if note.valid?
present note, with: Entities.const_get(note.class.name)
present note, with: Entities.const_get(note.class.name, false)
else
bad_request!("Note #{note.errors.messages}")
end
......
......@@ -49,7 +49,7 @@ module API
resource :todos do
helpers do
def issuable_and_awardable?(type)
obj_type = Object.const_get(type)
obj_type = Object.const_get(type, false)
 
(obj_type < Issuable) && (obj_type < Awardable)
rescue NameError
......
......@@ -3,7 +3,7 @@
module Banzai
module Filter
def self.[](name)
const_get("#{name.to_s.camelize}Filter")
const_get("#{name.to_s.camelize}Filter", false)
end
end
end
......@@ -4,7 +4,7 @@ module Banzai
module Pipeline
def self.[](name)
name ||= :full
const_get("#{name.to_s.camelize}Pipeline")
const_get("#{name.to_s.camelize}Pipeline", false)
end
end
end
......@@ -10,7 +10,7 @@ module Banzai
#
# This would return the `Banzai::ReferenceParser::IssueParser` class.
def self.[](name)
const_get("#{name.to_s.camelize}Parser")
const_get("#{name.to_s.camelize}Parser", false)
end
end
end
......@@ -30,7 +30,7 @@ module Bitbucket
end
 
def representation_class(type)
Bitbucket::Representation.const_get(type.to_s.camelize)
Bitbucket::Representation.const_get(type.to_s.camelize, false)
end
end
end
......@@ -30,7 +30,7 @@ module BitbucketServer
end
 
def representation_class(type)
BitbucketServer::Representation.const_get(type.to_s.camelize)
BitbucketServer::Representation.const_get(type.to_s.camelize, false)
end
end
end
......@@ -78,7 +78,7 @@ module Gitlab
end
 
def self.migration_class_for(class_name)
const_get(class_name)
const_get(class_name, false)
end
 
def self.enqueued_job?(queues, migration_class)
......
......@@ -23,7 +23,7 @@ module Gitlab
end
 
def request_cache(method_name, &method_key_block)
const_get(:RequestCacheExtension).module_eval do
const_get(:RequestCacheExtension, false).module_eval do
cache_key_method_name = "#{method_name}_cache_key"
 
define_method(method_name) do |*args|
......
......@@ -6,7 +6,7 @@ module Gitlab
module Policy
def self.fabricate(specs)
specifications = specs.to_h.map do |spec, value|
self.const_get(spec.to_s.camelize).new(value)
self.const_get(spec.to_s.camelize, false).new(value)
end
 
specifications.compact
......
......@@ -20,7 +20,7 @@ module Gitlab
 
def core_status
Gitlab::Ci::Status
.const_get(@status.capitalize)
.const_get(@status.capitalize, false)
.new(@subject, @user)
.extend(self.class.common_helpers)
end
......
......@@ -37,7 +37,7 @@ module Gitlab
 
def self.entry_class(strategy)
if strategy.present?
self.const_get(strategy.name)
self.const_get(strategy.name, false)
else
self::UnknownStrategy
end
......
......@@ -4,7 +4,7 @@ module Gitlab
module CycleAnalytics
module EventFetcher
def self.[](stage_name)
CycleAnalytics.const_get("#{stage_name.to_s.camelize}EventFetcher")
CycleAnalytics.const_get("#{stage_name.to_s.camelize}EventFetcher", false)
end
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment