Showing 197 of 197 total issues
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
File dependent_wrapped_spec.rb
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
module VersatileDiamond
using Patches::RichArray
module Organizers
Identical blocks of code found in 2 locations. Consider refactoring. Open
def inspect
sis = species.map(&:inspect)
nas = nodes.uniq(&:atom)
spops = nas.map(&:sub_properties).map(&:inspect)
pkns = nas.map do |n|
- Read upRead up
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 109.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
def inspect
sis = species.map(&:inspect)
nas = nodes.uniq(&:atom)
spops = nas.map(&:sub_properties).map(&:inspect)
pkns = nas.map do |n|
- Read upRead up
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 109.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Class AtomVariable
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class AtomVariable < Core::Variable
include LatticePositionReference
# @param [Instances::SpecieInstance] specie
# @return [Core::OpCall]
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 position
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def position(*atom_strs, **options)
target, spec, atom, used_atom_str = nil
atom_strs.each do |atom_str|
atom_sym = atom_str.to_sym
- 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
File base_context_provider.rb
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
module VersatileDiamond
using Patches::RichArray
module Generators
module Code
Class Graph
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class Graph
include Modules::ExcessPositionChecker
include Concepts::AtomsSwapper
extend Forwardable
Class SpecieBackbone
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class SpecieBackbone < BaseBackbone
extend Forwardable
# Initializes backbone by specie and grouped nodes of it
# @param [EngineCode] generator the major engine code generator
Method extends_if_possible
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def extends_if_possible(type, source, products, bonds_sum_limit, deep, &block)
specs = eval(type.to_s)
combinations(specs).each do |combination|
bonds_sum = specs.reduce(0) do |acc, spec|
acc +
- 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
File specie.rb
has 273 lines of code (exceeds 250 allowed). Consider refactoring. Open
module VersatileDiamond
using Patches::RichString
module Generators
module Code
Method convert_rate
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convert_rate(value, gases_num, dimension = nil)
return 0 if value == 0
dimension ||= @rate
syntax_error('.is_not_set') unless dimension
Class AtomsChangeUnit
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class AtomsChangeUnit
include Modules::ProcsReducer
# @param [Expressions::TargetsDictionary] dict
# @param [ChangesContextProvider] context
Method build_sequence_from
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def build_sequence_from(graph, nodes, visited)
result = []
nodes_queue = nodes.dup
until nodes_queue.empty?
- 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 SymmetriesDetector
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class SymmetriesDetector
include Modules::ListsComparer
include SymmetryHelper
extend Forwardable
Class TypicalReaction
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class TypicalReaction < SpeciesReaction
# Initializes typical reaction class code generator
def initialize(*)
super
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
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