openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Method generate_number has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def generate_number(options = {})
    options[:length] ||= NUMBER_LENGTH
    options[:letters] ||= NUMBER_LETTERS
    options[:prefix] ||= NUMBER_PREFIX

Severity: Minor
Found in app/models/concerns/number_generator.rb - About 1 hr 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_data_types has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def save_data_types
      errors = []
      optimize
      new_attributes = []
      valid = true
Severity: Minor
Found in app/models/setup/optimizer.rb - About 1 hr 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 method_missing has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def method_missing(symbol, *args)
      hashes = []
      if symbol.to_s.start_with?('all_')
        suffix = symbol.to_s.from('all_'.length).singularize
        fields.each { |field| hashes << self.class.send('auth_' + field.pluralize) if field.end_with?(suffix) }
Severity: Minor
Found in app/models/setup/authorization.rb - About 1 hr 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 create_authorization! has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def create_authorization!(auth_data = {})
      auth_class = self.class.preferred_authorization_class(provider)
      auth = auth_class.new(namespace: auth_data[:namespace], client_id: id, metadata: auth_data[:metadata])
      auth.name = auth_data[:name] || "#{provider.name.to_title} #{auth_class.to_s.split('::').last.to_title} #{auth.id}"
      if auth_class <= Setup::Oauth2Authorization
Severity: Minor
Found in app/models/setup/oauth_client.rb - About 1 hr 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 15 (exceeds 5 allowed). Consider refactoring.
Open

    def digest
      request.body.rewind
      options =
        begin
          JSON.parse(request.headers['X-Digest-Options'])
Severity: Minor
Found in app/controllers/api/v3/api_controller.rb - About 1 hr 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 a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def for(options)
        model_name = options[:name]
        cache_model = (cache_models = current_thread_cache)[model_name]
        unless (data_type = (options[:data_type] || (cache_model && cache_model.data_type)))
          raise Exception.new('name or data type required') unless model_name
Severity: Minor
Found in lib/mongoff/model.rb - About 1 hr 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 plain_query has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def plain_query(namespace_or_opts = nil)
    namespace =
      if (options = namespace_or_opts).is_a?(Hash)
        namespace_or_opts[:namespace]
      else
Severity: Minor
Found in lib/cenit/core_ext.rb - About 1 hr 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 check_string_format has 47 lines of code (exceeds 25 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 1 hr to fix

    Method new_user has 46 lines of code (exceeds 25 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 1 hr to fix

      Method validates_configuration has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def validates_configuration
            requires(:name)
            errors.add(:type, 'is not valid') unless type_enum.include?(type)
            errors.add(:style, 'is not valid') unless style_enum.include?(style)
            case type
      Severity: Minor
      Found in app/models/setup/legacy_translator.rb - About 1 hr to fix

        Method process_ldap_uri has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def process_ldap_uri(uri, template_parameters, options)
              username, password = check(template_parameters, :username, :password)
        
              auth_method = (template_parameters['auth_method'].presence || 'simple').to_sym
        
        
        Severity: Minor
        Found in app/models/concerns/setup/webhook_common.rb - About 1 hr to fix

          Method new_user has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def new_user
                data = (JSON.parse(request_data) rescue {}).keep_if { |key, _| USER_API_FIELDS.include?(key) }
                data = data.with_indifferent_access
                data.reverse_merge!(email: params[:email], password: pwd = params[:password])
                data.reject! { |_, value| value.nil? }
          Severity: Minor
          Found in app/controllers/api/v3/api_controller.rb - About 1 hr to fix

            Method authorize_account has 45 lines of code (exceeds 25 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 1 hr to fix

              Method start_consumer has 45 lines of code (exceeds 25 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 1 hr to fix

                Method run has 44 lines of code (exceeds 25 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 1 hr to fix

                  Method index has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def index
                      if (tenant = Tenant.where(id: params[:tenant_id]).first)
                        tenant.switch do
                          model = nil
                          if (model_desc = params[:model])
                  Severity: Minor
                  Found in app/controllers/file_controller.rb - About 1 hr to fix

                    Method index has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def index
                        skip_consent = false
                        if request.get?
                          if @errors.blank?
                            if @app_id && (@app_id.tenant == Account.current || @app_id.registered?)
                    Severity: Minor
                    Found in app/controllers/oauth_controller.rb - About 1 hr to fix

                      Method check_type has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def check_type(types, instance, _, _, options, schema)
                            return if instance.nil? && options[:skip_nulls]
                            if types
                              types = [types] unless types.is_a?(Array)
                              types = types.map(&:to_s).map(&:to_sym)
                      Severity: Minor
                      Found in lib/mongoff/validator.rb - About 1 hr to fix

                        Method to_method_name has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def to_method_name(taken = nil)
                            str = sym2word
                            {
                              '-' => 'minus',
                              '.' => 'dot'
                        Severity: Minor
                        Found in lib/cenit/core_ext.rb - About 1 hr to fix

                          Method run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def run(options = {})
                                    code = options[:code]
                                    split_style = options[:style].split('.') if options[:style].present?
                          
                                    format = options[:format] ||= split_style[0].to_sym if split_style[0].present?
                          Severity: Minor
                          Found in app/models/setup/transformation/action_view_transform.rb - About 1 hr 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