Showing 22 of 40 total issues
Method error_messages_for
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def error_messages_for(*params)
options = params.extract_options!.symbolize_keys
objects = Array.wrap(options.delete(:object) || params).map do |object|
object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Class ApplicationController
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
include Clearance::Authentication
include ApplicationMultifactorMethods
include TraceTagger
Method search_definition
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def search_definition(for_api: false) # rubocop:disable Metrics/MethodLength
query_str = @query
source_array = for_api ? api_source : ui_source
OpenSearch::DSL::Search.search do
Method error_messages_for
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def error_messages_for(*params)
options = params.extract_options!.symbolize_keys
objects = Array.wrap(options.delete(:object) || params).map do |object|
object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
Method search_data
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def search_data # rubocop:disable Metrics/MethodLength
if (latest_version = most_recent_version)
deps = latest_version.dependencies.to_a
versioned_links = links(latest_version)
end
Method compute_compact_index_info
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def compute_compact_index_info
requirements_and_dependencies.map do |r|
deps = []
if r[DEPENDENCY_REQUIREMENTS_INDEX]
reqs = r[DEPENDENCY_REQUIREMENTS_INDEX].split("@")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method check_mfa
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def check_mfa(user)
if user&.mfa_gem_signin_authorized?(otp)
return render_mfa_setup_required_error if user.mfa_required_not_yet_enabled?
return render_mfa_strong_level_required_error if user.mfa_required_weak_level_enabled?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method process
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process(version)
logger.tagged(version_id: version.id, name: version.rubygem.name, number: version.number, platform: version.platform) do
logger.info "Updating spec_sha256 for #{version.full_name}"
spec_path = "quick/Marshal.4.8/#{version.full_name}.gemspec.rz"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method view_template
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def view_template
self.title = t(".title")
return if not_configured
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method revoke
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def revoke
key_id = request.headers.fetch("GITHUB-PUBLIC-KEY-IDENTIFIER", "")
signature = request.headers.fetch("GITHUB-PUBLIC-KEY-SIGNATURE", "")
return render plain: "Missing GitHub Signature", status: :unauthorized if key_id.blank? || signature.blank?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method show
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def show
return unless params[:query].is_a?(String)
@error_msg, @gems = ElasticSearcher.new(params[:query], page: @page).search
return unless @gems
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method validate_gem_and_version
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_gem_and_version
if !@rubygem.hosted?
render plain: response_with_mfa_warning(t(:this_rubygem_could_not_be_found)),
status: :not_found
elsif !@rubygem.owned_by?(@api_key.user)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method valid_if_admin
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def valid_if_admin
return unless is_admin
errors.add(:is_admin, "missing oauth token") if oauth_token.blank?
errors.add(:is_admin, "missing info data") if info_data.blank?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method query
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def query
from = Time.zone.today.midnight - 1.week
to = Time.zone.now
if range.present?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method query
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def query
from = Time.zone.today.midnight - 1.week
to = Time.zone.now
if range.present?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method destroy
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def destroy
return render_api_key_forbidden unless @api_key.can_remove_owner?
owner = @rubygem.owners_including_unconfirmed.find_by_name(email_param)
if owner
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create
return render_api_key_forbidden unless @api_key.can_add_owner?
owner = User.find_by_name(email_param)
if owner
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return false if suggestions["suggest_name"][0]["options"].empty?
Method es_suggestions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def es_suggestions(gems)
return false if gems.size >= 1
return false unless gems.respond_to?(:response)
suggestions = gems.response["suggest"]
return false if suggestions.blank?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method index
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def index
return unless stale?(@rubygem)
cache_expiry_headers
set_surrogate_key "gem/#{@rubygem.name}"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"