aureooms/js-rational-field

View on GitHub

Showing 13 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

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

                if (n.match('/') !== null) {
                    if (base !== undefined)
                        throw new ValueError(
                            'RationalField#from: Third parameter makes no sense with fraction input.',
                        );
    Severity: Major
    Found in src/RationalField.js and 1 other location - About 3 hrs to fix
    src/RationalField.js on lines 22..31

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

    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

                if (n.match('[\\.\\|]') !== null) {
                    if (base !== undefined)
                        throw new ValueError(
                            'RationalField#from: Third parameter makes no sense with fixed point input.',
                        );
    Severity: Major
    Found in src/RationalField.js and 1 other location - About 3 hrs to fix
    src/RationalField.js on lines 33..42

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

    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

    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

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

                add(other) {
                    const [a, b] = add(this.n, this.d, other.n, other.d);
                    const [c, d] = simplify(a, b);
                    return new Rational(c, d);
                }
        Severity: Major
        Found in src/_make_rational_class.js and 2 other locations - About 1 hr to fix
        src/_make_rational_class.js on lines 32..36
        src/_make_rational_class.js on lines 38..42

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

        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 3 locations. Consider refactoring.
        Open

                sub(other) {
                    const [a, b] = sub(this.n, this.d, other.n, other.d);
                    const [c, d] = simplify(a, b);
                    return new Rational(c, d);
                }
        Severity: Major
        Found in src/_make_rational_class.js and 2 other locations - About 1 hr to fix
        src/_make_rational_class.js on lines 26..30
        src/_make_rational_class.js on lines 38..42

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

        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 3 locations. Consider refactoring.
        Open

                mul(other) {
                    const [a, b] = mul(this.n, this.d, other.n, other.d);
                    const [c, d] = simplify(a, b);
                    return new Rational(c, d);
                }
        Severity: Major
        Found in src/_make_rational_class.js and 2 other locations - About 1 hr to fix
        src/_make_rational_class.js on lines 26..30
        src/_make_rational_class.js on lines 32..36

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

        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

        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

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

              const {
                  add,
                  sub,
                  mul,
                  div,
          Severity: Major
          Found in src/_make_rational_class.js and 1 other location - About 1 hr to fix
          src/_make_methods.js on lines 46..58

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

          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

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

              return {
                  add,
                  sub,
                  mul,
                  div,
          Severity: Major
          Found in src/_make_methods.js and 1 other location - About 1 hr to fix
          src/_make_rational_class.js on lines 6..18

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

          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

          Severity
          Category
          Status
          Source
          Language