openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

(function () {
    Array.from(
        document.getElementsByClassName('responsive-box')
    ).forEach(
        rbox => Array.from(rbox.getElementsByClassName('devise box')).forEach(
app/assets/javascript/devise.js on lines 1..19

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 186.

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

Further Reading

File mapping_converter.rb has 464 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Setup
  class MappingConverter < ConverterTransformation
    include WithSourceOptions
    include Setup::TranslationCommon::ClassMethods

Severity: Minor
Found in app/models/setup/mapping_converter.rb - About 7 hrs to fix

    File utility.rb has 461 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'objspace'
    
    module Cenit
      class Utility
    
    
    Severity: Minor
    Found in lib/cenit/utility.rb - About 7 hrs to fix

      File converter.rb has 456 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Setup
        class Converter < LegacyTranslator
      
          include Setup::TranslationCommon::ClassMethods
      
      
      Severity: Minor
      Found in app/models/setup/converter.rb - About 6 hrs to fix

        Method do_map has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_map(source)
              plain_properties = []
              map_model.properties_schemas.each do |property, schema|
                plain_properties << property unless schema[MappingModel::SCHEMA_FLAG]
              end
        Severity: Minor
        Found in app/models/setup/mapping_converter.rb - About 6 hrs to fix

        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 do_map has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_map(source)
              plain_properties = []
              map_model.properties_schemas.each do |property, schema|
                plain_properties << property unless schema[MappingModel::SCHEMA_FLAG]
              end
        Severity: Minor
        Found in app/models/setup/converter.rb - About 6 hrs to fix

        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 for_each_node_starting_at has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
        Open

              def for_each_node_starting_at(record, options = {}, &block)
                stack = options[:stack]
                unless (visited = options[:visited])
                  visited = options[:visited] = Set.new
                end
        Severity: Minor
        Found in lib/cenit/utility.rb - About 6 hrs to fix

        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 Task has 49 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Task
            include CenitScoped
            include ClassHierarchyAware
            include CrossOrigin::CenitDocument
            include FieldsInspection
        Severity: Minor
        Found in app/models/setup/task.rb - About 6 hrs to fix

          Method check_patternProperties has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
          Open

              def check_patternProperties(patterns, instance, state, data_type, options)
                path = options[:path] || '#'
                unless (checked_properties = state[:checked_properties])
                  checked_properties = state[:checked_properties] = Set.new
                end
          Severity: Minor
          Found in lib/mongoff/validator.rb - About 6 hrs to fix

          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 eql_content? has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
          Open

                def eql_content?(a, b, key = nil, &block)
                  case a
                    when Hash
                      if b.is_a?(Hash)
                        if a.size < b.size
          Severity: Minor
          Found in lib/cenit/utility.rb - About 6 hrs to fix

          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 api_controller.rb has 446 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Api::V1
            class ApiController < ApplicationController
              before_action :authorize_account, :save_request_data, except: [:new_user, :cors_check, :auth]
              before_action :find_item, only: [:show, :destroy, :pull, :run]
              before_action :authorize_action, except: [:auth, :new_user, :cors_check, :push]
          Severity: Minor
          Found in app/controllers/api/v1/api_controller.rb - About 6 hrs to fix

            Method build_schema has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
            Open

                def build_schema
                  @discarding ||= []
                  schema = Mongoff::Model.base_schema.deep_merge('properties' => { 'id' => {} })
                  properties = schema['properties']
                  if model < ClassHierarchyAware
            Severity: Minor
            Found in app/models/setup/build_in_data_type.rb - About 6 hrs to fix

            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_on has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
            Open

                def process_on(hash_data, options = {})
                  options ||= {}
                  errors.clear
                  properties_locations.each do |property_location|
                    property_location.errors.clear
            Severity: Minor
            Found in app/models/setup/cross_collection_pull_parameter.rb - About 6 hrs to fix

            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 translate_export has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
            Open

                def translate_export(message, &block)
                  limit = translator.try(:bulk_source) ? lot_size || 1000 : 1
                  source_scope = sources(message)
                  max = source_scope.count - 1
                  translation_options = nil
            Severity: Minor
            Found in app/models/setup/flow.rb - About 6 hrs to fix

            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 save has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
            Open

                  def save(record, options = {})
                    saved = options[:saved_collector] || Set.new
                    if bind_references(record, options.delete(:bind_references))
                      success =
                        if record.try(:save_self_before_refs)
            Severity: Minor
            Found in lib/cenit/utility.rb - About 6 hrs to fix

            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 source_options has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
            Open

                def source_options(options, source_key_options = self.source_key_options)
                  data_type_key = source_key_options[:data_type_key] || :source_data_type
                  if (data_type = send(data_type_key) || options[data_type_key] || options[:data_type])
                    model = data_type.records_model
                    offset = options[:offset] || 0
            Severity: Minor
            Found in app/models/setup/with_source_options.rb - About 6 hrs to fix

            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 authorize_account has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
            Open

                def authorize_account
                  user = nil
                  if (auth_header = request.headers['Authorization'])
                    auth_header = auth_header.to_s.squeeze(' ').strip.split(' ')
                    if auth_header.length == 2
            Severity: Minor
            Found in app/controllers/api/v2/api_controller.rb - About 6 hrs to fix

            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 pretty_errors has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
            Open

                def pretty_errors(record, stack = Set.new)
                  return {} unless record
                  stack << record
                  errors = record.errors.messages.dup.with_indifferent_access
                  if errors.key?(:base) && !property?(:base)
            Severity: Minor
            Found in lib/mongoff/pretty_errors.rb - About 6 hrs to fix

            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 Control has 46 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Control
                include CanCan::Ability
            
                attr_reader :app, :action, :controller
                attr_accessor :view
            Severity: Minor
            Found in lib/cenit/control.rb - About 6 hrs to fix

              Method check_embedded_items has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
              Open

                    def check_embedded_items(item, record)
                      (item_model = record.class).model_properties_schemas.each do |property, schema|
                        next if schema['referenced']
                        next unless (property_value = item[property]) && (property_model = item_model.property_model(property))
                        next unless (property_data_type = property_model.data_type).get_referenced_by.present?
              Severity: Minor
              Found in app/models/setup/base_pull.rb - About 6 hrs to fix

              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

              Severity
              Category
              Status
              Source
              Language