brentlintner/synt

View on GitHub

Showing 25 of 25 total issues

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

      if (color) {
        console.log(cardinal.highlight(src.code, {
          firstline: src.pos.start.line,
          linenos: true
        }))
Severity: Major
Found in src/similar/print.ts and 1 other location - About 5 hrs to fix
src/similar/print.ts on lines 51..60

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

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 (color) {
        console.log(cardinal.highlight(cmp.code, {
          firstline: cmp.pos.start.line,
          linenos: true
        }))
Severity: Major
Found in src/similar/print.ts and 1 other location - About 5 hrs to fix
src/similar/print.ts on lines 30..39

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

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 (color) {
                console.log(cardinal.highlight(src.code, {
                    firstline: src.pos.start.line,
                    linenos: true
                }));
Severity: Major
Found in lib/similar/print.js and 1 other location - About 5 hrs to fix
lib/similar/print.js on lines 48..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 140.

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 (color) {
                console.log(cardinal.highlight(cmp.code, {
                    firstline: cmp.pos.start.line,
                    linenos: true
                }));
Severity: Major
Found in lib/similar/print.js and 1 other location - About 5 hrs to fix
lib/similar/print.js on lines 27..37

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

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 print has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

const print = (group, color) => {
    _.each(group, (results, sim) => {
        _.each(results, (result) => {
            const [src, cmp] = result;
            console.log("");
Severity: Minor
Found in lib/similar/print.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

Function print has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

const print = (
  group : synt.ParseResultGroup,
  color : boolean
) : void => {
  _.each(group, (results : synt.ParseResultMatchList, sim : string) => {
Severity: Minor
Found in src/similar/print.ts - 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

Function print has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const print = (group, color) => {
    _.each(group, (results, sim) => {
        _.each(results, (result) => {
            const [src, cmp] = result;
            console.log("");
Severity: Major
Found in lib/similar/print.js - About 2 hrs to fix

    Function print has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const print = (
      group : synt.ParseResultGroup,
      color : boolean
    ) : void => {
      _.each(group, (results : synt.ParseResultMatchList, sim : string) => {
    Severity: Minor
    Found in src/similar/print.ts - About 1 hr to fix

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

                  if (color) {
                      console.log(chalk.gray("in: ") + chalk.green(src.path));
                  }
                  else {
                      console.log(`in: ${src.path}`);
      Severity: Major
      Found in lib/similar/print.js and 1 other location - About 1 hr to fix
      lib/similar/print.js on lines 40..45

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

      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 (color) {
                          console.log(chalk.gray("in: ") + chalk.green(cmp.path));
                      }
                      else {
                          console.log(`in: ${cmp.path}`);
      Severity: Major
      Found in lib/similar/print.js and 1 other location - About 1 hr to fix
      lib/similar/print.js on lines 20..25

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

      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 (color) {
              console.log(chalk.gray("in: ") + chalk.green(src.path))
            } else {
              console.log(`in: ${ src.path }`)
            }
      Severity: Major
      Found in src/similar/print.ts and 1 other location - About 1 hr to fix
      src/similar/print.ts on lines 43..47

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

      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 (color) {
                console.log(chalk.gray("in: ") + chalk.green(cmp.path))
              } else {
                console.log(`in: ${ cmp.path }`)
              }
      Severity: Major
      Found in src/similar/print.ts and 1 other location - About 1 hr to fix
      src/similar/print.ts on lines 23..27

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

      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 configure has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const configure = () => {
        program
          .version(pkg.version)
          .command("analyze [paths...]")
          .alias("a")
      Severity: Minor
      Found in src/cli.ts - About 1 hr to fix

        Function false_positive has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const false_positive = (
          src : synt.ParseResult,
          cmp : synt.ParseResult,
          t_len : number
        ) => {
        Severity: Minor
        Found in src/similar.ts - About 1 hr to fix

          Function false_positive has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const false_positive = (src, cmp, t_len) => {
              const same_node = () => cmp.ast === src.ast;
              const size_is_too_different = () => {
                  const l1 = src.tokens.length;
                  const l2 = cmp.tokens.length;
          Severity: Minor
          Found in lib/similar.js - About 1 hr to fix

            Function configure has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const configure = () => {
                commander_1.program
                    .version(pkg.version)
                    .command("analyze [paths...]")
                    .alias("a")
            Severity: Minor
            Found in lib/cli.js - About 1 hr to fix

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

              const is_a_method_or_class = (node : ts.Node) : boolean =>
                _.some(FUNCTION_OR_CLASS_NODE, (kind) => kind === node.kind)
              Severity: Minor
              Found in src/similar/typescript.ts and 2 other locations - About 35 mins to fix
              src/similar/typescript.ts on lines 68..69
              src/similar/typescript.ts on lines 71..72

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

              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

              const is_a_base_node = (node : ts.Node) : boolean =>
                _.some(STOP_AT_NODES, (kind) => kind === node.kind)
              Severity: Minor
              Found in src/similar/typescript.ts and 2 other locations - About 35 mins to fix
              src/similar/typescript.ts on lines 71..72
              src/similar/typescript.ts on lines 74..75

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

              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

              const is_a_passthrough_node = (node : ts.Node) : boolean =>
                _.some(PASSTHROUGH_NODES, (kind) => kind === node.kind)
              Severity: Minor
              Found in src/similar/typescript.ts and 2 other locations - About 35 mins to fix
              src/similar/typescript.ts on lines 68..69
              src/similar/typescript.ts on lines 74..75

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

              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 is_ts_ancestor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              const is_ts_ancestor = (src, cmp) => {
                  let match = false;
                  let last = src.ast;
                  while (true) {
                      const { parent } = last;
              Severity: Minor
              Found in lib/similar.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

              Severity
              Category
              Status
              Source
              Language