MatteoRagni/cas-rb

View on GitHub

Showing 1,530 of 1,530 total issues

Method simplify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def simplify
      super
      return CAS::Zero if @x.include? CAS::Zero
      @x = @x - [CAS::One]
      return CAS::One if @x.size == 0
Severity: Minor
Found in lib/functions/fnc-prod.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

Method subs_rhs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def subs_rhs(dt)
      CAS::Help.assert(dt, Hash)
      sub = dt.keys.select { |e| e == @y }[0]
      if sub
        if dt[sub].is_a? CAS::Op
Severity: Minor
Found in lib/operators/bary-op.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

Function hookSearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function hookSearch() {
  var input  = $('#search-field').eq(0);
  var result = $('#search-results').eq(0);
  $(result).show();

Severity: Minor
Found in docs/js/darkfish.js - 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

Method to_ascii has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def to_ascii
      x_ascii, x_ul = @x.to_ascii
      y_ascii, y_ul = @y.to_ascii
      x_ll = x_ascii.size - x_ul
      y_ll = y_ascii.size - y_ul
Severity: Minor
Found in bin/graph2ascii.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

Method subs_lhs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def subs_lhs(dt)
      CAS::Help.assert(dt, Hash)
      sub = dt.keys.select { |e| e == @x }[0]
      if sub
        if dt[sub].is_a? CAS::Op
Severity: Minor
Found in lib/operators/bary-op.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

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    CAS::BoxConditionUpperClosed => Proc.new {
      ["double __t_#{x.object_id} = #{x.to_c};",
       "(__t_#{x.object_id} > #{lower.latex} && __t_#{x.object_id} <= #{upper.latex})"]
Severity: Minor
Found in lib/Mr.CAS/c.rb and 3 other locations - About 25 mins to fix
lib/Mr.CAS/c.rb on lines 110..112
lib/Mr.CAS/c.rb on lines 118..120
lib/Mr.CAS/c.rb on lines 122..124

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 30.

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

Further Reading

Method == has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def ==(op)
      # CAS::Help.assert(op, CAS::Op)
      if op.is_a? CAS::NaryOp
        return false if @x.size != op.x.size
        0.upto(@x.size - 1) do |i|
Severity: Minor
Found in lib/operators/nary-op.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

Method to_ascii has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def to_ascii
      x_ascii = []
      x_ul    = []
      x_ascii, x_ul = @x.to_ascii
      y_ascii, y_ul = @y.to_ascii
Severity: Minor
Found in bin/graph2ascii.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

Method subs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def subs(dt)
      CAS::Help.assert(dt, Hash)
      sub = dt.keys.select { |e| e == @x }[0]
      if sub
        if dt[sub].is_a? CAS::Op
Severity: Minor
Found in lib/operators/op.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

Method to_ascii has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def to_ascii
      x_ascii, x_ul = @x.to_ascii
      y_ascii, y_ul = @y.to_ascii
      x_ll = x_ascii.size - x_ul
      y_ll = y_ascii.size - y_ul
Severity: Minor
Found in bin/graph2ascii.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

Method include_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def include_type(type, lib)
      raise ArgumentError, "type must be a Symbol (:std, :local), received #{type}" unless [:std, :local].include? type
      raise ArgumentError, "lib must be a String, received a #{lib.class}" unless lib.is_a? String
      @include[type] << lib unless @include[type].include? lib
    end
Severity: Minor
Found in lib/Mr.CAS/c-opt.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

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    CAS::BoxConditionOpen => Proc.new {
      ["double __t_#{x.object_id} = #{x.to_c};",
       "(__t_#{x.object_id} > #{lower.latex} && __t_#{x.object_id} < #{upper.latex})"]
Severity: Minor
Found in lib/Mr.CAS/c.rb and 3 other locations - About 25 mins to fix
lib/Mr.CAS/c.rb on lines 114..116
lib/Mr.CAS/c.rb on lines 118..120
lib/Mr.CAS/c.rb on lines 122..124

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 30.

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

Further Reading

Method to_ascii has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def to_ascii
      x_ascii, x_ul = @x.to_ascii
      y_ascii, y_ul = @y.to_ascii
      x_ll = x_ascii.size - x_ul
      y_ll = y_ascii.size - y_ul
Severity: Minor
Found in bin/graph2ascii.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

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    CAS::BoxConditionLowerClosed => Proc.new {
      ["double __t_#{x.object_id} = #{x.to_c};",
       "(__t_#{x.object_id} >= #{lower.latex} && __t_#{x.object_id} < #{upper.latex})"]
Severity: Minor
Found in lib/Mr.CAS/c.rb and 3 other locations - About 25 mins to fix
lib/Mr.CAS/c.rb on lines 110..112
lib/Mr.CAS/c.rb on lines 114..116
lib/Mr.CAS/c.rb on lines 122..124

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 30.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  class SmallerEqual < CAS::Condition
    # Saves some required elements
    def representative
      @cond_type = "<="
      @cond_repr = "≤"
Severity: Minor
Found in lib/functions/fnc-conditions.rb and 1 other location - About 15 mins to fix
lib/functions/fnc-conditions.rb on lines 294..310

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 25.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  class GreaterEqual < CAS::Condition
    # Saves some required elements
    def representative
      @cond_type = ">="
      @cond_repr = "≥"
Severity: Minor
Found in lib/functions/fnc-conditions.rb and 1 other location - About 15 mins to fix
lib/functions/fnc-conditions.rb on lines 266..282

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 25.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    CAS::Asin   => Proc.new { |fd|
      u = @x.auto_diff(fd)
      CAS::AutoDiff::DualNumber.new Math.asin(u.x), -(Math.sin(u.x) * u.y)
Severity: Minor
Found in lib/Mr.CAS/auto-diff.rb and 1 other location - About 15 mins to fix
lib/Mr.CAS/auto-diff.rb on lines 117..119

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 25.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    CAS::Cos    => Proc.new { |fd|
      u = @x.auto_diff(fd)
      CAS::AutoDiff::DualNumber.new Math.cos(u.x), -(Math.sin(u.x) * u.y)
Severity: Minor
Found in lib/Mr.CAS/auto-diff.rb and 1 other location - About 15 mins to fix
lib/Mr.CAS/auto-diff.rb on lines 113..115

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 25.

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

Further Reading

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

require File.expand_path("lib/version.rb", File.dirname(__FILE__))
Severity: Minor
Found in mrbgem.rake by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Line is too long. [81/80]
Open

  s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
Severity: Minor
Found in Mr.CAS.gemspec by rubocop
Severity
Category
Status
Source
Language