openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Method connections has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def connections
      if @connections_cache
        @connections_cache
      else
        connections =
Severity: Minor
Found in app/models/concerns/setup/webhook_common.rb - About 2 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 > has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def >(other_scope)
      other_scope = Cenit::OauthScope.new(other_scope.to_s) unless other_scope.is_a?(Cenit::OauthScope)
      return false if (other_scope.auth? && !auth?) ||
        (other_scope.session_access? && !session_access?) ||
        (other_scope.offline_access? && !offline_access?) ||
Severity: Minor
Found in app/models/cenit/oauth_scope.rb - About 2 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 validate_configuration has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_configuration
      self.title = self.name if title.blank?
      validators_classes = Hash.new { |h, k| h[k] = [] }
      if validators.present?
        validators.each { |validator| validators_classes[validator.class] << validator }
Severity: Minor
Found in app/models/setup/file_data_type.rb - About 2 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 digest has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def digest
    status = :accepted
    json = {}
    if request.body.length > MAX_SIZE
      status = :bad_request
Severity: Minor
Found in app/controllers/hook_controller.rb - About 2 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 20 (exceeds 5 allowed). Consider refactoring.
Open

    def authorize_account
      user = nil

      # New key and token params.
      key = request.headers['X-Tenant-Access-Key'] || params.delete('X-Tenant-Access-Key')
Severity: Minor
Found in app/controllers/api/v1/api_controller.rb - About 2 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 push has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def push
      response =
        {
          success: success_report = Hash.new { |h, k| h[k] = [] },
          errors: broken_report = Hash.new { |h, k| h[k] = [] }
Severity: Minor
Found in app/controllers/api/v1/api_controller.rb - About 2 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 has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def for(app_id, scope, user_or_id, options = {})
        tenant = options[:tenant] || Cenit::MultiTenancy.tenant_model.current
        user_model = Cenit::MultiTenancy.user_model
        user =
          if user_model && user_or_id.is_a?(user_model)
Severity: Major
Found in app/models/cenit/oauth_access_token.rb - About 2 hrs to fix

    Class ApiController has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

      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]
        rescue_from Exception, with: :exception_handler
    Severity: Minor
    Found in app/controllers/api/v1/api_controller.rb - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                if property_schema['virtual'] ||
                   ((property_schema['edi'] || {})['discard'] && !(included_anyway = options[:including_discards] || options[:including].include?(property_name.to_sym))) ||
                   (can_be_referenced && referenced && !key_properties.include?(property_name)) ||
                   options[:ignore].include?(name.to_sym) ||
                   (options[:only].present? && options[:only].exclude?(name.to_sym) && !included_anyway)
      Severity: Critical
      Found in lib/edi/formater.rb - About 2 hrs to fix

        File legacy_translator.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Setup
          class LegacyTranslator < Translator
            include ReqRejValidator
            include SnippetCode
            # = Translator
        Severity: Minor
        Found in app/models/setup/legacy_translator.rb - About 2 hrs to fix

          File oauth_scope.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Cenit
            class OauthScope
          
              AUTH_TOKEN = :auth
          
          
          Severity: Minor
          Found in app/models/cenit/oauth_scope.rb - About 2 hrs to fix

            Method submit has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def submit(*args, &block)
                  if (options = args[0]).is_a?(Hash)
                    body_argument = options[:body]
                  else
                    body_argument = options
            Severity: Major
            Found in app/models/concerns/setup/webhook_common.rb - About 2 hrs to fix

              Method validate_instance has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def validate_instance(instance, options = {})
                    unless (visited = options[:visited])
                      visited = options[:visited] = Set.new
                    end
                    unless (soft_checked = visited.include?(instance))
              Severity: Major
              Found in lib/mongoff/validator.rb - About 2 hrs to fix

                Method for_each_ref has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def for_each_ref(visited = Set.new, params = {}, &block)
                      schema = params[:schema] || self.schema
                      not_found = params[:not_found]
                      refs = []
                      if (ref = schema['$ref'])
                Severity: Minor
                Found in app/models/setup/json_data_type.rb - About 2 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 inject_attributes has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def inject_attributes(json_schema)
                      refs = json_schema['$ref'] ||= nil
                      properties = json_schema['properties'] ||= {}
                      attributes.each do |a|
                        if a.is_a?(Xsd::AttributeGroup)
                Severity: Minor
                Found in lib/xsd/attribute_container_tag.rb - About 2 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 property_model has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def property_model(property)
                      property = property.to_s
                      model = nil
                      if schema.is_a?(Hash) && schema['type'] == 'object' && schema['properties'].is_a?(Hash) && (property_schema = schema['properties'][property])
                        if properties_models.key?(property)
                Severity: Minor
                Found in lib/mongoff/model.rb - About 2 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 << has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def << item
                      if item.is_a?(Record) || item.class.respond_to?(:data_type) || item.is_a?(Hash)
                        if item.is_a?(BSON::Document)
                          item = model.record_class.new(model, item, referenced || parent.new_record?)
                        elsif item.is_a?(Hash)
                Severity: Minor
                Found in lib/mongoff/record_array.rb - About 2 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 mongo_value has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    def mongo_value(value, field, schema = nil, &success_block)
                      field = '_id' if field.to_s == 'id'
                      types =
                        if !caching? || schema
                          mongo_type_for(field, schema)
                Severity: Minor
                Found in lib/mongoff/model.rb - About 2 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 to_method_name has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                  def to_method_name(taken = nil)
                    str = sym2word
                    {
                      '-' => 'minus',
                      '.' => 'dot'
                Severity: Minor
                Found in lib/cenit/core_ext.rb - About 2 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 record_to_edi has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def record_to_edi(data_type, options, schema, record, enclosed_property_name = nil)
                      output = []
                      return output unless record
                      field_sep = options[:field_separator]
                      segment =
                Severity: Major
                Found in lib/edi/formater.rb - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language