MatteoRagni/cas-rb

View on GitHub

Showing 1,530 of 1,530 total issues

Function prototype has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

Searcher.prototype = new function() {
  // search is performed in chunks of 1000 for non-blocking user input
  var CHUNK_SIZE = 1000;
  // do not try to find more than 100 results
  var MAX_RESULTS = 100;
Severity: Minor
Found in docs/js/searcher.js - About 1 day 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

Class has too many lines. [116/100]
Open

  class Op
    # Argument of the operation
    attr_reader :x

    # Initialize a new empty operation container. This is a virtual
Severity: Minor
Found in lib/operators/op.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class has too many lines. [104/100]
Open

  class NaryOp < CAS::Op
    # List of arguments of the operation
    attr_reader :x

    # Initialize a new empty N-elements operation container. This is
Severity: Minor
Found in lib/operators/nary-op.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Function prototype has 160 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Searcher.prototype = new function() {
  // search is performed in chunks of 1000 for non-blocking user input
  var CHUNK_SIZE = 1000;
  // do not try to find more than 100 results
  var MAX_RESULTS = 100;
Severity: Major
Found in docs/js/searcher.js - About 6 hrs to fix

    Function prototype has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    Search.prototype = $.extend({}, Navigation, new function() {
      var suid = 1;
    
      this.init = function() {
        var _this = this;
    Severity: Minor
    Found in docs/js/search.js - About 4 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 has too many lines. [30/10]
    Open

      def self.to_dot(op)
        CAS::Help.assert(op, CAS::Op)
        string = op.dot_graph
        labels = ""
    
    
    Severity: Minor
    Found in lib/Mr.CAS/graphviz.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for to_ascii is too high. [34.45/15]
    Open

        def to_ascii
          x_ascii, _ = @x.to_ascii
          y_ascii, _ = @y.to_ascii
    
          x_ascii = CAS::Ascii.normalize_ascii x_ascii
    Severity: Minor
    Found in bin/graph2ascii.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for to_ascii is too high. [33.9/15]
    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 by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for to_ascii is too high. [32.82/15]
    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 by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for to_ascii is too high. [32.82/15]
    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 by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for to_ascii is too high. [32.82/15]
    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 by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for reduce_associativity is too high. [30.82/15]
    Open

        def reduce_associativity
          pos, neg = [], []
    
          @x.each do |x_el|
            case x_el
    Severity: Minor
    Found in lib/functions/fnc-sum.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [24/10]
    Open

        def reduce_associativity
          pos, neg = [], []
    
          @x.each do |x_el|
            case x_el
    Severity: Minor
    Found in lib/functions/fnc-sum.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    File graph2ascii.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module CAS
      module Ascii
        def self.normalize_ascii(x_lines, type=nil)
          x_width = x_lines.map(&:size).max
          x_lines = x_lines.map { |l| l + (" " * (x_width - l.size)) }
    Severity: Minor
    Found in bin/graph2ascii.rb - About 3 hrs to fix

      Function prototype has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Search.prototype = $.extend({}, Navigation, new function() {
        var suid = 1;
      
        this.init = function() {
          var _this = this;
      Severity: Major
      Found in docs/js/search.js - About 3 hrs to fix

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

          class Diff
            def to_ascii
              x_ascii, x_ul = @x.to_ascii
              y_ascii, y_ul = @y.to_ascii
              x_ll = x_ascii.size - x_ul
        Severity: Major
        Found in bin/graph2ascii.rb and 1 other location - About 3 hrs to fix
        bin/graph2ascii.rb on lines 103..122

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

        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 Prod
            def to_ascii
              x_ascii, x_ul = @x.to_ascii
              y_ascii, y_ul = @y.to_ascii
              x_ll = x_ascii.size - x_ul
        Severity: Major
        Found in bin/graph2ascii.rb and 1 other location - About 3 hrs to fix
        bin/graph2ascii.rb on lines 80..99

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

        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

        Assignment Branch Condition size for normalize_ascii is too high. [25.73/15]
        Open

            def self.normalize_ascii(x_lines, type=nil)
              x_width = x_lines.map(&:size).max
              x_lines = x_lines.map { |l| l + (" " * (x_width - l.size)) }
              if (type == :complex and x_lines.size > 1)
                x_lines = x_lines.map { |l| l = "⎜#{l}⎟" }
        Severity: Minor
        Found in bin/graph2ascii.rb by rubocop

        This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

        Cyclomatic complexity for simplify is too high. [16/6]
        Open

            def simplify
              super
              return self if (@x == CAS::Zero and @y == CAS::Zero)
              return self if (@x == CAS::Infinity and @y == CAS::Infinity)
              return self if (@x == CAS::Infinity and @y == CAS::Zero)
        Severity: Minor
        Found in lib/functions/fnc-base.rb by rubocop

        This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

        An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

        Cyclomatic complexity for simplify is too high. [15/6]
        Open

            def simplify
              super
              return self if (@x == CAS::Zero and @y == CAS::Zero)
              return self if (@x == CAS::Infinity and @y == CAS::Infinity)
              return self if (@x == CAS::Infinity and @y == CAS::Zero)
        Severity: Minor
        Found in lib/functions/fnc-base.rb by rubocop

        This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

        An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

        Severity
        Category
        Status
        Source
        Language