openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

Consider simplifying this complex logical expression.
Open

          next if property_schema['virtual'] ||
                  ((property_schema['edi'] || {})['discard'] && !(included_anyway = options[:including_discards])) ||
                  options[:ignore].include?(name.to_sym) ||
                  (options[:only] && !options[:only].include?(name.to_sym) && !included_anyway)
Severity: Critical
Found in lib/edi/formater.rb - About 1 hr to fix

    Method run has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def run(message)
          algorithm_id = message[:algorithm_id]
          if (algorithm = agent_from_msg)
            result = algorithm.run(message[:input], self).capataz_slave
            klass = Setup::BuildInDataType::SCHEMA_TYPE_MAP.keys.detect do |type|
    Severity: Minor
    Found in app/models/setup/algorithm_execution.rb - About 1 hr to fix

      Method diff has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def diff(other_scope)
            other_scope = self.class.new(other_scope.to_s) unless other_scope.is_a?(self.class)
            diff = self.class.new
            if auth? && !other_scope.auth?
              diff.instance_variable_set(:@auth, true)
      Severity: Minor
      Found in app/models/cenit/oauth_scope.rb - About 1 hr to fix

        Method authorize has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def authorize
            if (tenant = Tenant.where(id: params[:tenant_id]).first)
              tenant.switch do
                errors = nil
                auth = @authorization = Setup::Authorization.where(id: params[:id]).first
        Severity: Minor
        Found in app/controllers/authorization_controller.rb - About 1 hr to fix

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

            def initialize(user)
              @deferred_abilities = []
          
              deferred_abilities <<
                if (@user = user)
          Severity: Minor
          Found in app/models/ability.rb - About 1 hr to fix

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

              Method new has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def new
                    response =
                      {
                        success: success_report = {},
                        errors: broken_report = {}
              Severity: Minor
              Found in app/controllers/api/v1/api_controller.rb - About 1 hr to fix

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                                if (object_ids = options[:object_ids])
                                  model.any_in(id: (limit ? object_ids[offset, limit] : object_ids.from(offset))).to_enum
                                elsif (objects = options[:objects])
                                  objects
                                else
                Severity: Major
                Found in app/models/setup/legacy_translator.rb and 1 other location - About 1 hr to fix
                app/models/setup/with_source_options.rb on lines 21..29

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 56.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                                elsif (object_ids = options[:object_ids])
                                  model.any_in(id: (limit ? object_ids[offset, limit] : object_ids.from(offset))).to_enum
                                elsif (objects = options[:objects])
                                  objects
                                else
                Severity: Major
                Found in app/models/setup/with_source_options.rb and 1 other location - About 1 hr to fix
                app/models/setup/legacy_translator.rb on lines 238..246

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 56.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def run(message)
                    if (script = agent_from_msg)
                      result = script.run(self)
                      klass = Setup::BuildInDataType::SCHEMA_TYPE_MAP.keys.detect do |type|
                        type && (result.class == type || result.class < type)
                Severity: Minor
                Found in app/models/script_execution.rb - About 1 hr to fix

                  Method source_ids_from has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def source_ids_from(message)
                        if (object_ids = message[:object_ids])
                          object_ids
                        elsif (id = message[:source_id])
                          [id]
                  Severity: Minor
                  Found in app/models/setup/flow.rb - About 1 hr to fix

                    Method to_map_schema has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def to_map_schema(sch)
                            if sch['type'] == 'object' && (properties = sch['properties']).is_a?(Hash)
                              new_properties = {}
                              id_optional = true
                              properties.each do |property, property_schema|
                    Severity: Minor
                    Found in app/models/setup/converter.rb - About 1 hr to fix

                      Method digest has 32 lines of code (exceeds 25 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

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

                          Method bundled_ruby_code has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                def bundled_ruby_code(algorithm)
                                  locals = %w(args)
                                  args_param = false
                                  i = -1
                                  params_initializer =
                          Severity: Minor
                          Found in lib/cenit/bundler_interpreter.rb - About 1 hr to fix

                            Method eql_content? has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                  def eql_content?(a, b, key = nil, &block)
                                    case a
                                      when Hash
                                        if b.is_a?(Hash)
                                          if a.size < b.size
                            Severity: Minor
                            Found in lib/cenit/utility.rb - About 1 hr to fix

                              Method init has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                    def init
                                      channel_mutex.lock
                                      if ENV['SKIP_RABBIT_MQ'].to_b
                                        puts 'RabbitMQ SKIPPED'
                                        false
                              Severity: Minor
                              Found in lib/cenit/rabbit.rb - About 1 hr to fix

                                Method request_token has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def request_token(params)
                                      http_client = create_http_client(token_url: token_endpoint, token_method: token_method.to_s.downcase.to_sym)
                                      token = http_client.get_token_with(:auth_code, params[:code]) do |parameters, headers|
                                        parameters.merge!(token_params(parameters, params)) if parameters
                                        headers.merge!(token_headers(headers, params)) if headers
                                Severity: Minor
                                Found in app/models/setup/oauth2_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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def run(message)
                                      collection_id = message[:collection_id]
                                      if (collection = Setup::Collection.where(id: collection_id).first)
                                        Setup::Collection::COLLECTING_PROPERTIES.each do |property|
                                          association = Setup::Collection.reflect_on_association(property)
                                Severity: Minor
                                Found in app/models/setup/namespace_collection.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 process_ftp has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def process_ftp(opts)
                                      result = nil
                                      path = URI.decode(opts[:path])
                                      username, password = check(opts[:template_parameters], :username, :password)
                                
                                
                                Severity: Minor
                                Found in app/models/concerns/setup/webhook_common.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