aureooms/js-rational-field

View on GitHub

Showing 6 of 13 total issues

Function _make_rational_class has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function _make_rational_class(domain, default_display_base) {
    const {
        add,
        sub,
        mul,
Severity: Major
Found in src/_make_rational_class.js - About 4 hrs to fix

    Function from has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        from(n, d = undefined, base = undefined) {
            // Always returns a rational object.
            const Element = this.element;
            if (n.constructor.prototype === Array.prototype) {
                base = d;
    Severity: Minor
    Found in src/RationalField.js - About 3 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

    domain has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    const domain = {
        name: 'ZZ',
        add: (a, b) => a.add(b),
        sub: (a, b) => a.sub(b),
        mul: (a, b) => a.mul(b),
    Severity: Minor
    Found in src/QQ.js - About 2 hrs to fix

      Function from has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          from(n, d = undefined, base = undefined) {
              // Always returns a rational object.
              const Element = this.element;
              if (n.constructor.prototype === Array.prototype) {
                  base = d;
      Severity: Major
      Found in src/RationalField.js - About 2 hrs to fix

        Function _make_methods has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function _make_methods(domain) {
            const primefactors = new Map();
            const factorize = __factorize__($2, iadd1, eq0, gt1, divmod);
            const ufactors = (n) => {
                if (!primefactors.has(n)) primefactors.set(n, new Set(factorize(n)));
        Severity: Minor
        Found in src/_make_methods.js - About 1 hr to fix

          Function _make_rational_class has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function _make_rational_class(domain, default_display_base) {
              const {
                  add,
                  sub,
                  mul,
          Severity: Minor
          Found in src/_make_rational_class.js - About 1 hr 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

          Severity
          Category
          Status
          Source
          Language