openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Method initialize has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(scope = '')
      @openid = Set.new
      @access = {}
      @super_methods = Set.new
      scope = scope.to_s.strip
Severity: Major
Found in app/models/cenit/oauth_scope.rb - About 2 hrs to fix

    Method mapping_schema has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def mapping_schema(target_data_type_id = nil)
            sch = {
              SCHEMA_FLAG.to_s => true,
              type: 'object',
              properties: {
    Severity: Major
    Found in app/models/setup/mapping_converter.rb - About 2 hrs to fix

      File control.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Cenit
        class Control
          include CanCan::Ability
      
          attr_reader :app, :action, :controller
      Severity: Minor
      Found in lib/cenit/control.rb - About 2 hrs to fix

        Method scan_dependencies_on has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def scan_dependencies_on(record, opts)
              return false if opts[:visited].include?(record) || record.is_a?(Setup::CenitDataType)
              opts[:visited] << record
              record.class.reflect_on_all_associations(:embeds_one,
                                                       :embeds_many,
        Severity: Minor
        Found in app/models/concerns/setup/collection_behavior.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 run has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def run(message)
              parser_options = (message['parser_options'] || {}).dup.with_indifferent_access
              parser_options[:create_callback] = -> model {
                unless authorize_action(action: :create, klass: model)
                  fail "Not authorized to create records of type #{model}"
        Severity: Minor
        Found in app/models/setup/asynchronous_persistence.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 get_embedded_schema has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_embedded_schema(ref, root_schema, root_name = '')
              fail "invalid format for embedded reference #{ref}" unless ref =~ %r{\A#(\/[a-z]+(_|([0-9]|[a-z])+)*)*\Z}
              fail "embedding itself (referencing '#')" if ref.eql?('#')
              tokens = ref.split('/')
              tokens.shift
        Severity: Minor
        Found in app/models/setup/schema_handler.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 check_required has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_required(properties, instance)
              return unless instance && properties.is_a?(Array)
              if instance.is_a?(Mongoff::Record)
                has_errors = false
                stored_properties = instance.orm_model.stored_properties_on(instance)
        Severity: Minor
        Found in lib/mongoff/validator.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 mapping_schema has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def mapping_schema(target_data_type_id = nil)
                sch = {
                  SCHEMA_FLAG.to_s => true,
                  type: 'object',
                  properties: {
        Severity: Major
        Found in app/models/setup/converter.rb - About 2 hrs to fix

          File json_data_type.rb has 266 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Setup
            class JsonDataType < DataType
              include Setup::SnippetCode
          
              origins Setup::CrossOriginShared::DEFAULT_ORIGINS
          Severity: Minor
          Found in app/models/setup/json_data_type.rb - About 2 hrs to fix

            Method validates_mapping has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def validates_mapping
                  mapping.validate
                  unless mapping.errors.present?
                    map_model.for_each_association do |a|
                      name = a[:name]
            Severity: Major
            Found in app/models/setup/mapping_converter.rb - About 2 hrs to fix

              Method validates_mapping has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def validates_mapping
                    mapping.validate
                    unless mapping.errors.present?
                      map_model.for_each_association do |a|
                        name = a[:name]
              Severity: Major
              Found in app/models/setup/converter.rb - About 2 hrs to fix

                File account.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require 'cenit/heroku_client'
                
                class Account
                  include Setup::CenitUnscoped
                  include Cenit::MultiTenancy
                Severity: Minor
                Found in app/models/account.rb - About 2 hrs to fix

                  Method check_patternProperties has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def check_patternProperties(patterns, instance, state, data_type, options)
                        path = options[:path] || '#'
                        unless (checked_properties = state[:checked_properties])
                          checked_properties = state[:checked_properties] = Set.new
                        end
                  Severity: Major
                  Found in lib/mongoff/validator.rb - About 2 hrs to fix

                    Consider simplifying this complex logical expression.
                    Open

                              if source_key_options[:bulk]
                                {
                                  source_key_options[:sources_key] || :sources =>
                                    if (selector = options[:selector])
                                      model.where(selector).to_enum
                    Severity: Critical
                    Found in app/models/setup/with_source_options.rb - About 2 hrs to fix

                      Class FileDataType has 22 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                        class FileDataType < DataType
                      
                          origins Setup::CrossOriginShared::DEFAULT_ORIGINS, :cenit
                      
                          validates_presence_of :namespace
                      Severity: Minor
                      Found in app/models/setup/file_data_type.rb - About 2 hrs to fix

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

                            def index
                              setup_viewport
                              items = select_items
                              if (distinct = params[:format]&.match(/\Adistinct\((.+)\)\Z/))
                                json = klass.collection.distinct(distinct[1], items.selector)
                        Severity: Major
                        Found in app/controllers/api/v3/api_controller.rb - About 2 hrs to fix

                          Method authorize_account has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def authorize_account(soft = false)
                              account_backup = Account.current
                              user_backup = User.current
                              Account.current = User.current = error_description = nil
                              if (auth_header = request.headers['Authorization'])
                          Severity: Major
                          Found in app/controllers/Oauth2AccountAuthorization.rb - About 2 hrs to fix

                            Method authorize_account has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def authorize_account
                                @authentication_method = nil
                                user = nil
                            
                                # New key and token params.
                            Severity: Major
                            Found in app/controllers/app_controller.rb - About 2 hrs to fix

                              Method cross_to has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def cross_to(origin = :default, criteria = {})
                                    COLLECTING_PROPERTIES.each do |property|
                                      r = reflect_on_association(property)
                                      next unless (model = r.klass).include?(Setup::CrossOriginShared)
                                      criteria = criteria.merge(:origin.ne => :default) if model == Setup::RemoteOauthClient || model == Setup::GenericAuthorizationClient
                              Severity: Minor
                              Found in app/models/concerns/setup/collection_behavior.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 condition_apply has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def condition_apply(obj, before, field_name, condition)
                                    obj_v = obj.try(field_name)
                                    cond_v = valuate(condition['v'], obj_v.class)
                                    obj_values =
                                      if cond_v.is_a?(String) || (cond_v.is_a?(Array) && cond_v.detect { |e| e.is_a?(String) })
                              Severity: Minor
                              Found in app/models/setup/triggers_formatter.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

                              Severity
                              Category
                              Status
                              Source
                              Language