openjaf/cenit

View on GitHub

Showing 829 of 829 total issues

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

    def translate_import(message, &block)
      options =
        {
          headers: message['headers'] || {},
          parameters: message['parameters'] || {},
Severity: Minor
Found in app/models/setup/flow.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 public has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def public
    if (tenant = Tenant.where(id: params[:tenant_id]).first)
      tenant.switch do
        if (data_type = Setup::FileDataType.where(id: params[:data_type_id]).first)
          if data_type.public_read
Severity: Minor
Found in app/controllers/file_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 associations has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def associations
      unless @associations
        @associations = {}.with_indifferent_access
        properties_schemas.each do |property, property_schema|
          if model.model_schema?(property_schema)
Severity: Minor
Found in lib/mongoff/model.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_propertyNames has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def check_propertyNames(schema, instance, state, data_type, options)
      path = options[:path] || '#'
      schema = data_type.merge_schema(schema)
      if instance.is_a?(Mongoff::Record)
        unless state[:instance_clear]
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 json_value has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def json_value(value, options, schema)
      case value
        when Time, Date, DateTime
          value = value.to_time
          if schema && schema['format'] == 'time'
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 json_value_of has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def json_value_of(value)
        return value unless value.is_a?(String)
        value = value.strip
        if value.blank?
          nil
Severity: Minor
Found in lib/cenit/utility.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 match? has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def match?(obj, criteria)
        criteria.each do |property_name, value|
          property_value =
            case obj
              when Hash
Severity: Minor
Found in lib/cenit/utility.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 install has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def install(options)
      collection = options[:collection]
      origin = options[:origin] || (self.origin == :default ? self.class.default_origin : self.origin)
      collection.add_dependencies if options[:add_dependencies]

Severity: Major
Found in app/models/setup/cross_shared_collection.rb - About 2 hrs to fix

    Method do_store_output has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def do_store_output(output)
          rc = []
          r = nil
    
          while output.capataz_proxy?
    Severity: Major
    Found in app/models/setup/algorithm.rb - About 2 hrs to fix

      Method save_references has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def save_references(record, options, saved, visited = Set.new)
              # TODO: Propagate error to parent relation...
              return true if visited.include?(record)
              visited << record
              if record.is_a?(Setup::Collection)
      Severity: Major
      Found in lib/cenit/utility.rb - About 2 hrs to fix

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

                  unless target_model.nil? || (target_model.is_a?(Class) && result.is_a?(target_association.klass)) ||
                    (result.is_a?(Mongoff::Record) && result.is_a?(target_model))
                    opts = opts.merge(discard_events: true).with_indifferent_access
                    if transformation.type == :Export && target_model.data_type.is_a?(Setup::FileDataType)
                      opts[:contentType] ||= transformation.mime_type
        Severity: Major
        Found in app/models/setup/mapping_converter.rb and 1 other location - About 2 hrs to fix
        app/models/setup/converter.rb on lines 105..115

        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 83.

        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

                  unless target_model.nil? || (target_model.is_a?(Class) && result.is_a?(target_association.klass)) ||
                    (result.is_a?(Mongoff::Record) && result.is_a?(target_model))
                    opts = opts.merge(discard_events: true).with_indifferent_access
                    if transformation.type == :Export && target_model.data_type.is_a?(Setup::FileDataType)
                      opts[:contentType] ||= transformation.mime_type
        Severity: Major
        Found in app/models/setup/converter.rb and 1 other location - About 2 hrs to fix
        app/models/setup/mapping_converter.rb on lines 116..126

        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 83.

        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

        File ability.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'cancan/model_adapters/mongoff_adapter'
        require 'setup/storage'
        
        class Ability
          include CanCan::Ability
        Severity: Minor
        Found in app/models/ability.rb - About 2 hrs to fix

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

              def index
                page = get_page
                res =
                  if klass
                    @render_options.delete(:inspecting)
          Severity: Major
          Found in app/controllers/api/v2/api_controller.rb - About 2 hrs to fix

            Method check_additionalProperties has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def check_additionalProperties(schema, 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

              File collection_behavior.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'cenit/cross_tracing_criteria'
              
              module Setup
                module CollectionBehavior
                  extend ActiveSupport::Concern
              Severity: Minor
              Found in app/models/concerns/setup/collection_behavior.rb - About 2 hrs to fix

                Method mapping_schema has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                      def mapping_schema(target_data_type_id = nil)
                        sch = {
                          SCHEMA_FLAG.to_s => true,
                          type: 'object',
                          properties: {
                Severity: Minor
                Found in app/models/setup/mapping_converter.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_requires has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def check_requires(json)
                      properties = json['properties']
                      if (required = json['required'])
                        if required.is_a?(Array)
                          required.each do |property|
                Severity: Minor
                Found in app/models/setup/json_data_type.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_definitions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def check_definitions(json, parent, defined_types, embedded_refs, root_schema)
                      if (defs = json['definitions'])
                        raise Exception.new('definitions format is invalid') unless defs.is_a?(Hash)
                        defs.each do |def_name, def_spec|
                          raise Exception.new("type definition '#{def_name}' is not an object type") unless def_spec.is_a?(Hash) && (def_spec['type'].nil? || def_spec['type'].eql?('object'))
                Severity: Minor
                Found in app/models/setup/json_data_type.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 default_refresh_token has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def default_refresh_token(authorization)
                      if (refresh_token = authorization.refresh_token) && is_time_to_refresh?(authorization)
                        fail 'Missing client configuration' unless (client = authorization.client)
                        http_response = HTTMultiParty.post(
                          authorization.token_endpoint,
                Severity: Minor
                Found in app/models/setup/base_oauth_provider.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