openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Method check_string_format has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def check_string_format(format, instance)
      case format

        when 'date', 'date-time', 'time'
          unless DATE_TIME_TYPES.any? { |type| instance.is_a?(type) }
Severity: Minor
Found in lib/mongoff/validator.rb - About 4 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 new_user has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def new_user
      data = (JSON.parse(@webhook_body) rescue {}).keep_if { |key, _| %w(email password password_confirmation token code).include?(key) }
      data = data.with_indifferent_access
      data.reverse_merge!(email: params[:email], password: pwd = params[:password], password_confirmation: params[:password_confirmation] || pwd)
      status = :not_acceptable
Severity: Minor
Found in app/controllers/api/v1/api_controller.rb - About 4 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 find_record has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

      def find_record(conditions, *scopes)
        scopes.each do |original_scope|
          scope = original_scope
          match_conditions = {}
          begin
Severity: Minor
Found in lib/cenit/utility.rb - About 4 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 start_consumer has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

      def start_consumer
        if init
          new_rabbit_consumer = RabbitConsumer.create(channel: "#{connection.host}:#{connection.local_port} (#{channel.id})",
                                                      tag: channel.generate_consumer_tag(Cenit.rabbit_mq_queue))
          new_consumer = queue.subscribe(consumer_tag: new_rabbit_consumer.tag, manual_ack: true) do |delivery_info, properties, body|
Severity: Minor
Found in lib/cenit/rabbit.rb - About 4 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 run has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def run(message)
      message = message.with_indifferent_access
      data_types =
        case source = message[:source]
        when nil # All data types
Severity: Minor
Found in app/models/setup/data_type_expansion.rb - About 4 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 lookup_messages has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

      def lookup_messages(opts = {})
        channel_mutex.lock
        if channel && !channel.closed?
          dispatched_ids = []
          tenant_tasks = {}
Severity: Minor
Found in lib/cenit/rabbit.rb - About 4 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 rabbit.rb has 349 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'json'
require 'openssl'
require 'bunny'

module Cenit
Severity: Minor
Found in lib/cenit/rabbit.rb - About 4 hrs to fix

    Class User has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User
      include Setup::CenitUnscoped
      include Cenit::MultiTenancy::UserScope
      extend DeviseOverrides
      include CredentialsGenerator
    Severity: Minor
    Found in app/models/user.rb - About 4 hrs to fix

      Consider simplifying this complex logical expression.
      Open

            if schema.is_a?(Hash) && (schema = schema.reject { |key, _| %w(types contextual_params data filter group xml unique title description edi format example enum readOnly default visible referenced_by maxProperties minProperties auto export_embedded exclusive).include?(key) })
              property_dt = nil
              ns = data_type.namespace
              if (ref = schema['$ref']).is_a?(Array)
                ref = nil
      Severity: Critical
      Found in lib/mongoff/model.rb - About 4 hrs to fix

        Method prepare has 108 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.prepare
              return self if @init_done
              @init_done = true
        
              actions = Setup::Models.all.reduce(Set.new) do |set, model|
        Severity: Major
        Found in app/models/ability.rb - About 4 hrs to fix

          Method record_to_xml_element has 108 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def record_to_xml_element(data_type, schema, record, xml_doc, enclosed_property_name, options, namespaces)
                return unless record
                if Cenit::Utility.json_object?(record)
                  return Nokogiri::XML({ enclosed_property_name => record }.to_xml(dasherize: false)).root.first_element_child
                end
          Severity: Major
          Found in lib/edi/formater.rb - About 4 hrs to fix

            Method process_connection has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                def process_connection(template_parameters, verbose_response, last_response, options, &block)
                  conformed_url = template_parameters[:url]
                  conformed_path = template_parameters[:path]
                  body = template_parameters[:body]
                  halt_anyway = false
            Severity: Minor
            Found in app/models/concerns/setup/webhook_common.rb - About 4 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 algorithm.rb has 341 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'rkelly'
            
            module Setup
              class Algorithm
                include SnippetCode
            Severity: Minor
            Found in app/models/setup/algorithm.rb - About 4 hrs to fix

              Method validate_slug has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_slug
                    check_taken = true
                    unless slug.present?
                      candidate =
                        if (candidate = slug_candidate).blank?
              Severity: Minor
              Found in app/models/concerns/setup/slug.rb - About 4 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 run has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run(message)
                    if (hook = Cenit::Hook.where(id: message[:hook_id]).first)
                      slug = message[:slug]
                      if (hook_channel = hook.channels.where(slug: slug).first)
                        if (data_type = hook_channel.data_type)
              Severity: Minor
              Found in app/models/setup/hook_data_processing.rb - About 4 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_data has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_data(data)
                    case schema_type
                    when :json_schema
                      unless data.is_a?(Hash)
                        data =
              Severity: Minor
              Found in app/models/setup/schema.rb - About 4 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 new has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                  def new
                    parser_options = self.parser_options.dup
                    if klass.is_a?(Class) && klass < FieldsInspection
                      parser_options[:inspect_fields] = Account.current.nil? || !::User.super_access?
                    end
              Severity: Minor
              Found in app/controllers/api/v3/api_controller.rb - About 4 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 index has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                  def index
                    page = get_page
                    res =
                      if klass
                        @render_options.delete(:inspecting)
              Severity: Minor
              Found in app/controllers/api/v2/api_controller.rb - About 4 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_store has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                  def do_store(json, key, value, options, schema = {}, store_anyway = false)
                    if options[:nqnames]
                      key = key.to_s.split(':').last
                    end
                    if value.nil?
              Severity: Minor
              Found in lib/edi/formater.rb - About 4 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 run has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run(message)
                    if (data_type = agent_from_msg)
                      begin
                        config = data_type.file_store_config
                        total = data_type.all.count.to_f
              Severity: Minor
              Found in app/models/setup/file_store_migration.rb - About 3 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