newmen/versatile-diamond

View on GitHub
analyzer/lib/organizers/atom_properties.rb

Summary

Maintainability
F
5 days
Test Coverage

Class AtomProperties has 73 methods (exceeds 20 allowed). Consider refactoring.
Open

    class AtomProperties
      include Modules::ListsComparer
      include Modules::OrderProvider
      include Lattices::BasicRelations

Severity: Major
Found in analyzer/lib/organizers/atom_properties.rb - About 1 day to fix

    File atom_properties.rb has 571 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module VersatileDiamond
      using Patches::RichArray
      using Patches::RichString
    
      module Organizers
    Severity: Major
    Found in analyzer/lib/organizers/atom_properties.rb - About 1 day to fix

      Method to_s has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

            def to_s
              return @_to_s if @_to_s
      
              name = atom_name.to_s
      
      
      Severity: Minor
      Found in analyzer/lib/organizers/atom_properties.rb - About 3 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 to_s has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def to_s
              return @_to_s if @_to_s
      
              name = atom_name.to_s
      
      
      Severity: Major
      Found in analyzer/lib/organizers/atom_properties.rb - About 2 hrs to fix

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

              def merge_props(other, &block)
                same_unit_states = UNIT_STATES.all? { |mn| send(mn) == other.send(mn) }
                is_valid_lts = lattice == other.lattice ||
                          (!lattice && other.lattice) || (lattice && !other.lattice)
        
        
        Severity: Minor
        Found in analyzer/lib/organizers/atom_properties.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 common_plus has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def common_plus(other, total_props)
                lattices_num = total_props[:nbr_lattices].select(&:last).size
                total_unfixed = total_props[:relevants].include?(UNFIXED)
                return if total_unfixed && lattices_num > 1
        
        
        Severity: Minor
        Found in analyzer/lib/organizers/atom_properties.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 safe_plus has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def safe_plus(other)
                both = [self, other]
                smallests_of_both = both.map do |props|
                  props.smallests.empty? ? Set[props] : props.smallests
                end
        Severity: Minor
        Found in analyzer/lib/organizers/atom_properties.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 initialize has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def initialize(*args)
                if args.one?
                  arg = args.first
                  if arg.is_a?(Array)
                    @props = arg
        Severity: Minor
        Found in analyzer/lib/organizers/atom_properties.rb - About 1 hr to fix

          Method initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(*args)
                  if args.one?
                    arg = args.first
                    if arg.is_a?(Array)
                      @props = arg
          Severity: Minor
          Found in analyzer/lib/organizers/atom_properties.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 remake_relations has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def remake_relations(spec, atom)
                  # only bonds without relevat states and positions
                  bonds = spec.relations_of(atom, with_atoms: true).select { |_, r| r.bond? }
          
                  result = []
          Severity: Minor
          Found in analyzer/lib/organizers/atom_properties.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def <=>(other)
                  if self == other
                    0
                  elsif include?(other)
                    1
          Severity: Minor
          Found in analyzer/lib/organizers/atom_properties.rb - About 1 hr to fix

            Method common_plus has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def common_plus(other, total_props)
                    lattices_num = total_props[:nbr_lattices].select(&:last).size
                    total_unfixed = total_props[:relevants].include?(UNFIXED)
                    return if total_unfixed && lattices_num > 1
            
            
            Severity: Minor
            Found in analyzer/lib/organizers/atom_properties.rb - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                        elsif arg.is_a?(Hash)
                          @props = [
                            arg[:atom_name] || raise(ArgumentError, 'Undefined atom name'),
                            arg[:valence] || raise(ArgumentError, 'Undefined valence'),
                            arg[:lattice] || raise(ArgumentError, 'Undefined lattice'),
              Severity: Major
              Found in analyzer/lib/organizers/atom_properties.rb - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                          if rel.multi?
                            g = many_nls_groups.find { |g| g.size == rel.arity }
                            frl = g && g.pop
                            frl && (rel.arity - 1).times(&g.public_method(:pop))
                          else
                Severity: Major
                Found in analyzer/lib/organizers/atom_properties.rb - About 40 mins to fix

                  Method contained_in? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def contained_in?(other)
                          return false unless same_basic_values?(other)
                          return false unless other.contain_all_relevants?(self)
                          if incoherent? && other.relevant?
                            other.eq_relevant_bonds?(self)
                  Severity: Minor
                  Found in analyzer/lib/organizers/atom_properties.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

                  Method produce_props has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def produce_props(other, &block)
                          unit_props = UNIT_STATES.zip([atom_name, valence]).to_h
                          all_lattices = [self, other].map(&:lattice).uniq
                          any_unfixed = [self, other].any?(&:unfixed?)
                          iterating_lattices =
                  Severity: Minor
                  Found in analyzer/lib/organizers/atom_properties.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

                  There are no issues that match your filters.

                  Category
                  Status