opensheetmusicdisplay/opensheetmusicdisplay

View on GitHub
src/VexFlowPatch/src/svgcontext.js

Summary

Maintainability
F
3 days
Test Coverage

File svgcontext.js has 505 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.
// @author Gregory Ristow (2015)

import { Vex } from './vex';

Severity: Major
Found in src/VexFlowPatch/src/svgcontext.js - About 1 day to fix

    SVGContext has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class SVGContext {
      constructor(element) {
        // element is the parent DOM object
        this.element = element;
        // Create the SVG in the SVG namespace:
    Severity: Minor
    Found in src/VexFlowPatch/src/svgcontext.js - About 5 hrs to fix

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

        constructor(element) {
          // element is the parent DOM object
          this.element = element;
          // Create the SVG in the SVG namespace:
          this.svgNS = 'http://www.w3.org/2000/svg';
      Severity: Minor
      Found in src/VexFlowPatch/src/svgcontext.js - About 1 hr to fix

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

          setFont(family, size, weight) {
            // Unlike canvas, in SVG italic is handled by font-style,
            // not weight. So: we search the weight argument and
            // apply bold and italic to weight and style respectively.
            let bold = false;
        Severity: Minor
        Found in src/VexFlowPatch/src/svgcontext.js - About 1 hr to fix

          Function setFont has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            setFont(family, size, weight) {
              // Unlike canvas, in SVG italic is handled by font-style,
              // not weight. So: we search the weight argument and
              // apply bold and italic to weight and style respectively.
              let bold = false;
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.js - About 45 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

          Function arc has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            arc(x, y, radius, startAngle, endAngle, antiClockwise) {
              function normalizeAngle(angle) {
                while (angle < 0) {
                  angle += Math.PI * 2;
                }
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.js - About 35 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

          Function fill has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            fill(attributes) {
              // If our current path is set to glow, make it glow
              this.glow();
          
              const path = this.create('path');
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.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

          Function arcHelper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            arcHelper(x, y, radius, startAngle, endAngle, antiClockwise) {
              const x1 = x + radius * Math.cos(startAngle);
              const y1 = y + radius * Math.sin(startAngle);
          
              const x2 = x + radius * Math.cos(endAngle);
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.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

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

            moveTo(x, y) {
              this.path += 'M' + x + ' ' + y;
              this.pen.x = x;
              this.pen.y = y;
              return this;
          Severity: Major
          Found in src/VexFlowPatch/src/svgcontext.js and 1 other location - About 1 hr to fix
          src/VexFlowPatch/src/svgcontext.js on lines 413..418

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

          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

            lineTo(x, y) {
              this.path += 'L' + x + ' ' + y;
              this.pen.x = x;
              this.pen.y = y;
              return this;
          Severity: Major
          Found in src/VexFlowPatch/src/svgcontext.js and 1 other location - About 1 hr to fix
          src/VexFlowPatch/src/svgcontext.js on lines 406..411

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

          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

              this.attributes = {
                'stroke-width': 0.3,
                'fill': 'black',
                'stroke': 'black',
                'stroke-dasharray': 'none',
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.js and 1 other location - About 50 mins to fix
          src/VexFlowPatch/src/svgcontext.js on lines 69..78

          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

              this.background_attributes = {
                'stroke-width': 0,
                'fill': 'white',
                'stroke': 'white',
                'stroke-dasharray': 'none',
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.js and 1 other location - About 50 mins to fix
          src/VexFlowPatch/src/svgcontext.js on lines 58..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 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

                if (weight.indexOf('italic') !== -1) {
                  weight = weight.replace(/italic/g, '');
                  italic = true;
                }
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.js and 1 other location - About 40 mins to fix
          src/VexFlowPatch/src/svgcontext.js on lines 151..154

          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

                if (weight.indexOf('bold') !== -1) {
                  weight = weight.replace(/bold/g, '');
                  bold = true;
                }
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.js and 1 other location - About 40 mins to fix
          src/VexFlowPatch/src/svgcontext.js on lines 146..149

          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

              this.path += 'M' + x1 + ' ' + y1 + ' A' +
                radius + ' ' + radius + ' 0 ' + largeArcFlag + ' ' + sweepFlag + ' ' +
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.js and 1 other location - About 30 mins to fix
          src/VexFlowPatch/src/svgcontext.js on lines 421..427

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

          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

              this.path += 'C' +
                x1 + ' ' +
                y1 + ',' +
                x2 + ' ' +
                y2 + ',' +
          Severity: Minor
          Found in src/VexFlowPatch/src/svgcontext.js and 1 other location - About 30 mins to fix
          src/VexFlowPatch/src/svgcontext.js on lines 497..498

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

          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