staltz/cycle

View on GitHub
devtool/src/panel/graph/view.ts

Summary

Maintainability
F
3 days
Test Coverage

Function renderNodeLabel has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function renderNodeLabel(node: StreamGraphNode, zap: Zap | null, style: string): VNode {
  let label = '';
  if (zap) {
    // MUTATION!
    if (Array.isArray(zap.value)) {
Severity: Minor
Found in devtool/src/panel/graph/view.ts - About 2 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

File view.ts has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {VNode, svg} from '@cycle/dom';
import {StreamGraphNode, StreamGraphEdge, Zap} from '../../graphSerializer';
import styles from './styles';

export const DIAGRAM_PADDING_H = 30;
Severity: Minor
Found in devtool/src/panel/graph/view.ts - About 2 hrs to fix

    Function renderSourceOrSinkNode has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function renderSourceOrSinkNode(node: StreamGraphNode, zaps: Array<Zap>) {
      const index = zaps.map(zap => zap.id).indexOf(node.id);
      const zap = index === -1 ? null : zaps[index];
      const P = 5; // text padding
      const hook = {
    Severity: Minor
    Found in devtool/src/panel/graph/view.ts - About 1 hr to fix

      Function renderNodeLabel has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function renderNodeLabel(node: StreamGraphNode, zap: Zap | null, style: string): VNode {
        let label = '';
        if (zap) {
          // MUTATION!
          if (Array.isArray(zap.value)) {
      Severity: Minor
      Found in devtool/src/panel/graph/view.ts - About 1 hr to fix

        Function renderCommonNode has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function renderCommonNode(node: StreamGraphNode, zaps: Array<Zap>): VNode {
          const index = zaps.map(zap => zap.id).indexOf(node.id);
          const zap = index === -1 ? null : zaps[index];
        
          return svg.g([
        Severity: Minor
        Found in devtool/src/panel/graph/view.ts - About 1 hr to fix

          Function renderCommonNode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function renderCommonNode(node: StreamGraphNode, zaps: Array<Zap>): VNode {
            const index = zaps.map(zap => zap.id).indexOf(node.id);
            const zap = index === -1 ? null : zaps[index];
          
            return svg.g([
          Severity: Minor
          Found in devtool/src/panel/graph/view.ts - 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

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

                attrs: {
                  x: (node.x || 0) - node.width * 0.5 + DIAGRAM_PADDING_H,
                  y: (node.y || 0) - node.height * 0.5 + DIAGRAM_PADDING_V,
                  rx: 9,
                  ry: 9,
          Severity: Major
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 2 hrs to fix
          devtool/src/panel/graph/view.ts on lines 137..144

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

          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

                attrs: {
                  x: (node.x || 0) - node.width * 0.5 + DIAGRAM_PADDING_H,
                  y: (node.y || 0) - node.height * 0.5 + DIAGRAM_PADDING_V,
                  rx: 9,
                  ry: 9,
          Severity: Major
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 2 hrs to fix
          devtool/src/panel/graph/view.ts on lines 90..97

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

          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: {
                  [styles.sourceOrSinkNodeStyle]: !zap,
                  [styles.nodeZapNextStyle]: zap && zap.type === 'next',
                  [styles.nodeZapErrorStyle]: zap && zap.type === 'error',
                  [styles.nodeZapCompleteStyle]: zap && zap.type === 'complete',
          Severity: Major
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 2 hrs to fix
          devtool/src/panel/graph/view.ts on lines 131..136

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

          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: {
                  [styles.activeNodeStyle]: !zap,
                  [styles.nodeZapNextStyle]: zap && zap.type === 'next',
                  [styles.nodeZapErrorStyle]: zap && zap.type === 'error',
                  [styles.nodeZapCompleteStyle]: zap && zap.type === 'complete',
          Severity: Major
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 2 hrs to fix
          devtool/src/panel/graph/view.ts on lines 84..89

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

          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

                  d: `M ${points.map(({ x, y }) => `${x} ${y}`).join(' ')}`,
          Severity: Major
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 1 hr to fix
          devtool/src/panel/graph/view.ts on lines 227..227

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

          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

                d: `M ${points.map(({ x, y }) => `${x} ${y}`).join(' ')}`,
          Severity: Major
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 1 hr to fix
          devtool/src/panel/graph/view.ts on lines 246..246

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

          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

            const points = edgeData.points
              .map(({x, y}) => ({ x: x + DIAGRAM_PADDING_H, y: y + DIAGRAM_PADDING_V }));
          Severity: Minor
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 50 mins to fix
          devtool/src/panel/graph/view.ts on lines 211..213

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

          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

            const points = edgeData.points.map(({x, y}) =>
              ({ x: x + DIAGRAM_PADDING_H, y: y + DIAGRAM_PADDING_V }),
            );
          Severity: Minor
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 50 mins to fix
          devtool/src/panel/graph/view.ts on lines 237..238

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

          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

                tspanElem.setAttribute('x',
                  String(DIAGRAM_PADDING_H + (node.x || 0) - textElem.clientWidth * 0.5 - P * 0.4),
                );
          Severity: Minor
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 40 mins to fix
          devtool/src/panel/graph/view.ts on lines 68..70

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

          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

                tspanElem.setAttribute('y',
                  String(DIAGRAM_PADDING_V + (node.y || 0) + textElem.clientHeight * 0.5 - P * 0.5),
                );
          Severity: Minor
          Found in devtool/src/panel/graph/view.ts and 1 other location - About 40 mins to fix
          devtool/src/panel/graph/view.ts on lines 65..67

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

          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

          There are no issues that match your filters.

          Category
          Status