MatteoRagni/cas-rb

View on GitHub
lib/functions/fnc-piecewise.rb

Summary

Maintainability
A
0 mins
Test Coverage

Line is too long. [85/80]
Open

  # From this class other classes will inherit like `CAS::Max` and `CAS::Min` classes
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Line is too long. [87/80]
Open

    #  * **returns**: `CAS::Piecewise` with derivated functions and unchanged condition
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Line is too long. [108/80]
Open

      "\\mathrm{#{@type}}\\left( \\begin{array}{c} #{@x.to_latex} \\\\ #{@y.to_latex} \\end{array} \\right)"
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Line is too long. [93/80]
Open

    # warning:: Piecewise functions are in general not differentiable. Thus differentiability
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Line is too long. [96/80]
Open

  # will return a `CAS::Piecewise` (since condition will not depend anymore on object functions)
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Use && instead of and.
Open

        return ((@x == op.x) and (@y == op.y) and (@condition == op.condition))
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Line is too long. [96/80]
Open

  # will return a `CAS::Piecewise` (since condition will not depend anymore on object functions)
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

When defining the == operator, name its argument other.
Open

    def ==(op)
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop makes sure that certain binary operator methods have their sole parameter named other.

Example:

# bad
def +(amount); end

# good
def +(other); end

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

      @type = "max"
Severity: Minor
Found in lib/functions/fnc-piecewise.rb 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. [87/80]
Open

    # Derivative of a function is performed as derivative of the two internal functions
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Use only ascii symbols in comments.
Open

  # Min class represent a piecewise in which the condition is `f(x) ≤ g(x)`. Derivate a `CAS::Min`
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).

Example:

# bad
# Translates from English to 日本語。

# good
# Translates from English to Japanese

Do not place comments on the same line as the end keyword.
Open

  end # MinMax
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

Example:

# bad
if condition
  statement
end # end if

# bad
class X # comment
  statement
end

# bad
def x; end # comment

# good
if condition
  statement
end

# good
class X # :nodoc:
  y
end

Line is too long. [98/80]
Open

  # Max class represent a piecewise in which the condition is `f(x) ≥ g(x)`. Derivate a `CAS::Max`
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Use only ascii symbols in comments.
Open

  # Max class represent a piecewise in which the condition is `f(x) ≥ g(x)`. Derivate a `CAS::Max`
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).

Example:

# bad
# Translates from English to 日本語。

# good
# Translates from English to Japanese

Redundant return detected.
Open

      return CAS::Piecewise.new(@x.diff(v).simplify, @y.diff(v).simplify, @condition)
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Line is too long. [99/80]
Open

    # To initialize `CAS::Max` only the two functions are necessary. The condition is automatically
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Do not use :: for method calls.
Open

    CAS::Min.new(x, y, CAS::smaller_equal(x, y))
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).

Example:

# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)

# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)

Line is too long. [92/80]
Open

  # Class MinMax is an intermediate class for Min and Max functions. It contains shared code
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Line is too long. [99/80]
Open

    # To initialize `CAS::Min` only the two functions are necessary. The condition is automatically
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Use && instead of and.
Open

        return ((@x == op.x) and (@y == op.y) and (@condition == op.condition))
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Do not use :: for method calls.
Open

      super(x, y, CAS::smaller_equal(x, y))
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).

Example:

# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)

# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)

Do not place comments on the same line as the end keyword.
Open

  end # Max
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

Example:

# bad
if condition
  statement
end # end if

# bad
class X # comment
  statement
end

# bad
def x; end # comment

# good
if condition
  statement
end

# good
class X # :nodoc:
  y
end

Line is too long. [85/80]
Open

      return CAS::Piecewise.new(@x.diff(v).simplify, @y.diff(v).simplify, @condition)
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Do not use :: for method calls.
Open

      super(x, y, CAS::greater_equal(x, y))
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).

Example:

# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)

# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)

Do not place comments on the same line as the end keyword.
Open

  end # Min
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

Example:

# bad
if condition
  statement
end # end if

# bad
class X # comment
  statement
end

# bad
def x; end # comment

# good
if condition
  statement
end

# good
class X # :nodoc:
  y
end

Line is too long. [81/80]
Open

    # Checks if two `CAS::Piecewise` are equal. Checks equality on all functions+
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Line is too long. [118/80]
Open

      "\\left\\{ \\begin{array}{lr} #{@x.to_latex} & #{@condition.to_latex} \\\\ #{@y.to_latex} \\end{array} \\right."
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Missing top-level module documentation comment.
Open

module CAS
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Script file fnc-piecewise.rb doesn't have execute permission.
Open

#!/usr/bin/env ruby
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

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

      @type = "min"
Severity: Minor
Found in lib/functions/fnc-piecewise.rb 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

    #  d  |  f(x)   if condition(x) is True     | f'(x)   if condition(x) is True
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Line is too long. [98/80]
Open

  # Min class represent a piecewise in which the condition is `f(x) ≤ g(x)`. Derivate a `CAS::Min`
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

      if self.class != op.class
Severity: Minor
Found in lib/functions/fnc-piecewise.rb by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

There are no issues that match your filters.

Category
Status