openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Method authorize_action has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def authorize_action(options = {})
      success = true
      if klass
        action_symbol =
          case @_action_name
Severity: Minor
Found in app/controllers/api/v2/api_controller.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

Method push has a Cognitive Complexity of 22 (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/v2/api_controller.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

Method evolve_hash has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

      def evolve_hash(hash)
        if (association = model.associations[field]) && association.referenced?
          operators = {}
          sub_criteria = {}
          hash.each do |key, value|
Severity: Minor
Found in lib/mongoff/criteria.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

Method json_object? has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

      def json_object?(obj, options = {})
        case obj
          when Hash
            if options[:recursive]
              obj.keys.each { |k| return false unless k.is_a?(String) }
Severity: Minor
Found in lib/cenit/utility.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

Method prepare_options has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def prepare_options(options)
      include_id = options[:include_id]
      [:ignore, :only, :embedding, :inspecting, :including].each do |option|
        value = (options[option] || [])
        value = [value] unless value.is_a?(Enumerable)
Severity: Minor
Found in lib/edi/formater.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

Method translate_export has 77 lines of code (exceeds 25 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: Major
Found in app/models/setup/flow.rb - About 3 hrs to fix

    Method execute has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def execute(options = {})
          task_desc = description.presence || "Task ##{id}"
          if running? || !Cenit::Locker.lock(self)
            notify(message: "Executing task ##{id} at #{Time.now} but it is already running")
          else
    Severity: Major
    Found in app/models/setup/task.rb - About 3 hrs to fix

      Method check_properties has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def check_properties(json_schema, options = {})
            object_schema =
              case json_schema['type']
              when 'object'
                json_schema
      Severity: Major
      Found in app/models/setup/schema_handler.rb - About 3 hrs to fix

        Class DelayedMessage has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class DelayedMessage
            include CenitUnscoped
        
            deny :all
        
        
        Severity: Minor
        Found in app/models/setup/delayed_message.rb - About 3 hrs to fix

          Class Algorithm has 26 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Algorithm
              include SnippetCode
              include NamespaceNamed
              include Taggable
              # = Algorithm
          Severity: Minor
          Found in app/models/setup/algorithm.rb - About 3 hrs to fix

            Class CrossSharedCollection has 26 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class CrossSharedCollection
                include CenitUnscoped
                include CrossOrigin::CenitDocument
                include CollectionBehavior
                include Taggable
            Severity: Minor
            Found in app/models/setup/cross_shared_collection.rb - About 3 hrs to fix

              Class OauthScope has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class OauthScope
              
                  AUTH_TOKEN = :auth
              
                  SESSION_ACCESS_TOKEN = :session_access
              Severity: Minor
              Found in app/models/cenit/oauth_scope.rb - About 3 hrs to fix

                Method process_message has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def process_message(message, options = {})
                        unless message.is_a?(Hash)
                          message =
                            begin
                              JSON.parse(message)
                Severity: Major
                Found in lib/cenit/rabbit.rb - About 2 hrs to fix

                  Method authorize_action has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def authorize_action(options = {})
                        action = options[:action] || @_action_name
                        success = true
                        if klass
                          action_symbol =
                  Severity: Minor
                  Found in app/controllers/api/v3/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 update has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def update
                        @payload.each do |_, message|
                          message = message.first if message.is_a?(Array)
                          @parser_options[:add_only] = true
                          @item.send(@payload.update_method, message, @parser_options)
                  Severity: Minor
                  Found in app/controllers/api/v2/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 mongo_type_for has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def mongo_type_for(field, schema, property_model = nil)
                        property_model ||= property_model(field) if field
                        schema ||= property_schema(field)
                        if property_model && schema['referenced']
                          property_model.mongo_type_for(:_id, nil) #TODO Set schema parameter default to nil
                  Severity: Minor
                  Found in lib/mongoff/metadata_access.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 edi_value has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def edi_value(record, property_name, property_schema, property_model, options)
                        if (value = record[property_name]).nil?
                          value = property_schema['default'] || ''
                        end
                        value = property_model.to_string(value) if property_model
                  Severity: Minor
                  Found in lib/edi/formater.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 callback has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def callback
                      redirect_uri = nil
                      error = params[:error]
                      if (cenit_token = CallbackAuthorizationToken.where(token: params[:state] || session[:oauth_state]).first) &&
                        (User.current = cenit_token.set_current_tenant!.owner) && (auth = cenit_token.authorization)
                  Severity: Major
                  Found in app/controllers/oauth_controller.rb - About 2 hrs to fix

                    Method pull has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def pull(shared_collection, pull_request = {})
                            pull_request = pull_request.with_indifferent_access
                            pull_request = pull_request(shared_collection, pull_request) if pull_request[:pull_data].nil?
                            errors = []
                            if pull_request[:missing_parameters].blank?
                    Severity: Major
                    Found in app/models/setup/base_pull.rb - About 2 hrs to fix

                      Method enqueue has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def enqueue(message, &block)
                              message = message.with_indifferent_access
                              task_description = message[:task_description]
                              auto_retry = message[:auto_retry].presence || Setup::Task.auto_retry_enum.first
                              scheduler = message.delete(:scheduler)
                      Severity: Major
                      Found in lib/cenit/rabbit.rb - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language