Showing 575 of 596 total issues
File doi.rb
has 2078 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "maremma"
require "benchmark"
class Doi < ApplicationRecord
self.ignored_columns += [:publisher]
Method query
has a Cognitive Complexity of 194 (exceeds 5 allowed). Consider refactoring. Open
def query(query, options = {})
# support scroll api
# map function is small performance hit
if options[:scroll_id].present? && options.dig(:page, :scroll)
begin
- 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
File query_type.rb
has 1225 lines of code (exceeds 250 allowed). Consider refactoring. Open
class QueryType < BaseObject
extend_type
field :members, MemberConnectionWithTotalType, null: false do
argument :query, String, required: false
Class Doi
has 156 methods (exceeds 20 allowed). Consider refactoring. Open
class Doi < ApplicationRecord
self.ignored_columns += [:publisher]
PUBLISHER_JSON_SCHEMA = Rails.root.join("app", "models", "schemas", "doi", "publisher.json")
audited only: %i[doi url creators contributors titles publisher_obj publication_year types descriptions container sizes formats version_info language dates identifiers related_identifiers related_items funding_references geo_locations rights_list subjects schema_version content_url landing_page aasm_state source reason]
Method query
has 548 lines of code (exceeds 25 allowed). Consider refactoring. Open
def query(query, options = {})
# support scroll api
# map function is small performance hit
if options[:scroll_id].present? && options.dig(:page, :scroll)
begin
File indexable.rb
has 966 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Indexable
extend ActiveSupport::Concern
require "aws-sdk-sqs"
File client.rb
has 882 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Client < ApplicationRecord
SUBJECTS_JSON_SCHEMA = Rails.root.join("app", "models", "schemas", "client", "subjects.json")
audited except: %i[
system_email
service_contact
File event.rb
has 878 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Event < ApplicationRecord
# include helper module for query caching
include Cacheable
# include event processing
File doi_item.rb
has 861 lines of code (exceeds 250 allowed). Consider refactoring. Open
module DoiItem
include BaseInterface
include Bolognese::MetadataUtils
REGISTRATION_AGENCIES = {
File provider.rb
has 812 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "countries"
class Provider < ApplicationRecord
audited except: %i[
globus_uuid
Method index
has 367 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "name"
{ "doi" => { order: "asc" } }
Method query
has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring. Open
def self.query(query, options = {})
# support scroll api
# map function is small performance hit
if options[:scroll_id].present? && options.dig(:page, :scroll)
begin
- 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
File datacite_dois_controller.rb
has 708 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "uri"
require "base64"
require "pp"
class DataciteDoisController < ApplicationController
Identical blocks of code found in 2 locations. Consider refactoring. Open
indexes :provider,
type: :object,
properties: {
id: { type: :keyword },
uid: { type: :keyword },
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 369.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
indexes :provider,
type: :object,
properties: {
id: { type: :keyword },
uid: { type: :keyword },
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 369.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Class QueryType
has 71 methods (exceeds 20 allowed). Consider refactoring. Open
class QueryType < BaseObject
extend_type
field :members, MemberConnectionWithTotalType, null: false do
argument :query, String, required: false
Method index
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "relevance"
{ "_score" => { order: "desc" } }
- 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 250 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.query(query, options = {})
# support scroll api
# map function is small performance hit
if options[:scroll_id].present? && options.dig(:page, :scroll)
begin
Method index
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "name"
{ "doi" => { order: "asc" } }
- 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 197 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "relevance"
{ "_score" => { order: "desc" } }