BrandyMint/bitrix_on_rails

View on GitHub

Showing 7 of 7 total issues

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

    def unserialize(value, type, user_type = nil)
      return nil unless value

      case type
        when 'N'
Severity: Minor
Found in lib/bitrix_on_rails/iblock_element_prop_s.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 acts_as_iblock_element_prop_s has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def acts_as_iblock_element_prop_s(iblock_id, iblock_element_class)
    extend ClassMethods
    include InstanceMethods

    @m_prop_class = "IblockElementPropM#{iblock_id}"
Severity: Minor
Found in lib/bitrix_on_rails/iblock_element_prop_s.rb - About 1 hr to fix

    Method create_prop_classes has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.create_prop_classes(iblock_id, iblock_element_class)
        const_name = "IblockElementPropS#{iblock_id}"
        unless Object.const_defined? const_name
          c = Class.new(::ActiveRecord::Base) do
            extend BitrixOnRails::IblockElementPropS
    Severity: Minor
    Found in lib/bitrix_on_rails/iblock_element.rb - About 1 hr to fix

      Method define_delegated_methods has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def define_delegated_methods(scope, id, is_class=false)
            # TODO Проверять не создали ли мы такие методы уже в рамках класса
            # это так если у класса установлен @iblock_id
      
            return if scope.is_a?(IblockElement) and scope.class.iblock_id
      Severity: Minor
      Found in app/models/iblock.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 define_iblock_class has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.define_iblock_class(iblock_id, options = {})
          iblock_version = Iblock.find(iblock_id).version
      
          iblock_element_class = send("create_iblock_v#{iblock_version}_class", iblock_id, options[:extended_class], options[:extended_by])
      
      
      Severity: Minor
      Found in lib/bitrix_on_rails/iblock_element.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 has_infoblock has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def has_infoblock(iblock_id, foreign_key)
            prop_s_name = "iblock_element_prop_s#{iblock_id}".to_sym
            iblock_element_class = BitrixOnRails.infoblocks[iblock_id]
      
            has_one prop_s_name, :class_name => "::IblockElementPropS#{iblock_id}", :foreign_key => foreign_key , :autosave => true
      Severity: Minor
      Found in lib/bitrix_on_rails/active_record.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 encode_in_deep has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def PHP.encode_in_deep(val, encoding)
          if val.is_a? Array
            val = val.map { |v| encode_in_deep(v, encoding) }
          elsif val.is_a? Hash
            val.each_pair do |k,v|
      Severity: Minor
      Found in lib/php_serialize_encoded.rb - About 35 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

      Severity
      Category
      Status
      Source
      Language