openjaf/cenit

View on GitHub
app/models/setup/build_in_data_type.rb

Summary

Maintainability
D
3 days
Test Coverage

Class BuildInDataType has 54 methods (exceeds 20 allowed). Consider refactoring.
Open

  class BuildInDataType
    include SchemaHandler
    include DataTypeParser

    attr_reader :model
Severity: Major
Found in app/models/setup/build_in_data_type.rb - About 7 hrs to fix

    Method build_schema has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_schema
          @discarding ||= []
          schema = Mongoff::Model.base_schema.deep_merge('properties' => { 'id' => {} })
          properties = schema['properties']
          if model < ClassHierarchyAware
    Severity: Minor
    Found in app/models/setup/build_in_data_type.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 build_in_data_type.rb has 364 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'edi/formater'
    require 'xsd/core_ext'
    
    module Setup
      class BuildInDataType
    Severity: Minor
    Found in app/models/setup/build_in_data_type.rb - About 4 hrs to fix

      Method build_schema has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def build_schema
            @discarding ||= []
            schema = Mongoff::Model.base_schema.deep_merge('properties' => { 'id' => {} })
            properties = schema['properties']
            if model < ClassHierarchyAware
      Severity: Major
      Found in app/models/setup/build_in_data_type.rb - About 3 hrs to fix

        Method store_fields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def store_fields(instance_variable, *fields)
              if fields
                fail 'Illegal argument' unless fields.present?
                fields = [fields] unless fields.is_a?(Enumerable)
                instance_variable_set(instance_variable, fields.flatten.collect(&:to_s).uniq.select(&:present?))
        Severity: Minor
        Found in app/models/setup/build_in_data_type.rb - About 45 mins 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 all_data_type_storage_collections_names has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def all_data_type_storage_collections_names
              if model < CrossOrigin::CenitDocument
                origins = model.origins.select { |origin| Setup::Crossing.authorized_crossing_origins.include?(origin) }
                origins.collect do |origin|
                  if origin == :default
        Severity: Minor
        Found in app/models/setup/build_in_data_type.rb - About 25 mins 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

        There are no issues that match your filters.

        Category
        Status