Method setup_by_other
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def setup_by_other(target, other, own, foreign)
return own if target.gas?
original_own = own
own = SpecificAtom.new(own) unless own.specific?
- Read upRead up
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 swap_atom
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def swap_atom(spec, from, to, reverse_too: true)
is_source = @source.include?(spec)
@result.each do |_, mapping|
mapping.each do |specs, atoms|
- Read upRead up
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 find_positions_for
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def find_positions_for(reaction)
return if complex_source.one? || complex_source.size == complex_products.size
main_spec, idx =
complex_source.one? ? [complex_source.first, 0] : [complex_products.first, 1]
- Read upRead up
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
Class MappingResult
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class MappingResult
attr_reader :source, :products, :reaction_type
# Recombines passed mapping result to list where each item is two spec_atom
File mapping_result.rb
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
module VersatileDiamond
module Mcs
# Contains reactants and mapping result (how change each atom of stuctures)
class MappingResult
Method deep_find_positions
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def deep_find_positions(reaction, main_spec, main_atoms, position)
crystal = main_atoms.first.lattice.instance
return unless crystal.flatten?(position)
rel_groups = main_atoms.map do |a|
- Read upRead up
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 deep_find_positions
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def deep_find_positions(reaction, main_spec, main_atoms, position)
crystal = main_atoms.first.lattice.instance
return unless crystal.flatten?(position)
rel_groups = main_atoms.map do |a|
Method setup_by_other
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_by_other(target, other, own, foreign)
return own if target.gas?
original_own = own
own = SpecificAtom.new(own) unless own.specific?
Method swap
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def swap(target, from, to)
return if from.simple?
mirror = SpeciesComparator.make_mirror(from, to)
trg = instance_variable_get(:"@#{target}")
- Read upRead up
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
Consider simplifying this complex logical expression. Open
own.unfixed! if !is_own_relevant_lazy.call && !own.lattice &&
own.valence - target.external_bonds_for(original_own) == 1 &&
((other.gas? && !other.simple?) || diff.include?(Unfixed.property))