openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

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

  def check_index
    if request.get?
      @errors << 'Missing client_id.' unless (@client_id = params[:client_id])
      if (@response_type = params[:response_type])
        @errors << 'Invalid response_type.' unless @response_type == 'code'
Severity: Minor
Found in app/controllers/oauth_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 hash_decode has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

      def hash_decode(value)
        case value
        when Hash
          r = nil
          if value.size == 1
Severity: Minor
Found in lib/cenit/xmlrpc.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 task.rb has 423 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Method authorize_account has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

      def authorize_account
        @authentication_method = nil
        user = nil
    
        # New key and token params.
    Severity: Minor
    Found in app/controllers/app_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 record_to_hash has 152 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def record_to_hash(record, options, referenced, enclosed_model, max_entries, viewport)
          return record if Cenit::Utility.json_object?(record)
          model =
            begin
              record.orm_model
    Severity: Major
    Found in lib/edi/formater.rb - About 6 hrs to fix

      Method execute has a Cognitive Complexity of 39 (exceeds 5 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: Minor
      Found in app/models/setup/task.rb - About 5 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 39 (exceeds 5 allowed). Consider refactoring.
      Open

          def new
            response = {}
            %w(success warnings errors).each { |key| response[key.to_sym] = Hash.new { |h, k| h[k] = [] } }
            @payload.each do |root, message|
              if (data_type = @payload.data_type_for(root))
      Severity: Minor
      Found in app/controllers/api/v2/api_controller.rb - About 5 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 core_ext.rb has 411 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Module
        class << self
      
          def demongoize(object)
            object.to_s.constantize
      Severity: Minor
      Found in lib/cenit/core_ext.rb - About 5 hrs to fix

        Method each_entry has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

            def each_entry(&block)
              state.clear if state[:done]
              if decompress_content?
                begin
                  Zip::InputStream.open(StringIO.new(data.read)) do |zis|
        Severity: Minor
        Found in app/models/concerns/setup/data_iterator.rb - About 5 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 38 (exceeds 5 allowed). Consider refactoring.
        Open

            def source_options(options, 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/legacy_translator.rb - About 5 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_http_connection has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_http_connection(connection, template_parameters, verbose_response, last_response, options, &block)
              template_parameters[:method] ||= method
              conformed_url = template_parameters[:url]
              conformed_path = template_parameters[:path]
              parameters = connection.conformed_parameters(template_parameters)
        Severity: Minor
        Found in app/models/concerns/setup/webhook_common.rb - About 5 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 38 (exceeds 5 allowed). Consider refactoring.
        Open

            def index
              if klass
                @items =
                  if @criteria.present?
                    if (sort_key = @criteria.delete(:sort_by))
        Severity: Minor
        Found in app/controllers/api/v1/api_controller.rb - About 5 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_parse_edi has 143 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def do_parse_edi(data_type, model, content, json_schema, start, field_sep, segment_sep, report, options = {})
                record = options[:record] || options[:new_record] || model.new
                json = options[:json]
                fields = options[:fields]
                segment = options[:segment]
        Severity: Major
        Found in lib/edi/parser.rb - About 5 hrs to fix

          Method new_user has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

              def new_user
                data = (JSON.parse(@webhook_body) rescue {}).keep_if { |key, _| USER_API_FIELDS.include?(key) }
                data = data.with_indifferent_access
                data.reverse_merge!(email: params[:email], password: pwd = params[:password], password_confirmation: params[:password_confirmation] || pwd)
                data.reject! { |_, value| value.nil? }
          Severity: Minor
          Found in app/controllers/api/v2/api_controller.rb - About 5 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 a Cognitive Complexity of 37 (exceeds 5 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: Minor
          Found in app/controllers/oauth_controller.rb - About 5 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 record.rb has 396 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Mongoff
            class Record
              include Savable
              include Destroyable
              include Edi::Filler
          Severity: Minor
          Found in lib/mongoff/record.rb - About 5 hrs to fix

            Class Account has 41 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Account
              include Setup::CenitUnscoped
              include Cenit::MultiTenancy
              include CredentialsGenerator
              include FieldsInspection
            Severity: Minor
            Found in app/models/account.rb - About 5 hrs to fix

              Method do_parse_xml has 136 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def do_parse_xml(data_type, model, element, options, json_schema, record = nil, new_record = nil, enclosed_property = nil, container = nil, container_schema = nil)
                      updating = !(record.nil? && new_record.nil?) || options[:add_only]
                      json_schema = data_type.merge_schema(json_schema)
                      name = json_schema['edi']['segment'] if json_schema['edi']
                      name ||= enclosed_property || model.data_type.name
              Severity: Major
              Found in lib/edi/parser.rb - About 5 hrs to fix

                Method new has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                Open

                  def new
                    if (provider = params[:with])
                      redirect_to "/app/#{::Cenit::OpenId.app_key}?with=#{provider}&redirect_uri=#{Cenit.homepage}#{session_path(resource_name)}"
                    elsif (code = params[:code])
                      if (user = ::Cenit::OpenId.get_user_by(code))
                Severity: Minor
                Found in app/controllers/sessions_controller.rb - About 5 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_http_connection has 135 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def process_http_connection(connection, template_parameters, verbose_response, last_response, options, &block)
                      template_parameters[:method] ||= method
                      conformed_url = template_parameters[:url]
                      conformed_path = template_parameters[:path]
                      parameters = connection.conformed_parameters(template_parameters)
                Severity: Major
                Found in app/models/concerns/setup/webhook_common.rb - About 5 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language