nfroidure/svgicons2svgfont

View on GitHub
src/index.js

Summary

Maintainability
F
4 days
Test Coverage

Function _transform has 189 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _transform(svgIconStream, _unused, svgIconStreamCallback) {
    // Parsing each icons asynchronously
    const saxStream = Sax.createStream(true);
    const parents = [];
    const transformStack = [new Matrix()];
Severity: Major
Found in src/index.js - About 7 hrs to fix

    File index.js has 471 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable complexity,prefer-reflect,max-len,newline-after-var */
    /* eslint no-multi-str:0 */
    
    'use strict';
    
    
    Severity: Minor
    Found in src/index.js - About 7 hrs to fix

      Function _flush has 173 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _flush(svgFontFlushCallback) {
          this.glyphs.forEach((glyph) => {
            if (
              glyph.defaultHeight ||
              glyph.defaultWidth ||
      Severity: Major
      Found in src/index.js - About 6 hrs to fix

        Function _flush has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          _flush(svgFontFlushCallback) {
            this.glyphs.forEach((glyph) => {
              if (
                glyph.defaultHeight ||
                glyph.defaultWidth ||
        Severity: Minor
        Found in src/index.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

        Function tagShouldRender has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function tagShouldRender(curTag, parents) {
          let values;
        
          return !parents.some((tag) => {
            if (
        Severity: Minor
        Found in src/index.js - About 1 hr to fix

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

            _transform(svgIconStream, _unused, svgIconStreamCallback) {
              // Parsing each icons asynchronously
              const saxStream = Sax.createStream(true);
              const parents = [];
              const transformStack = [new Matrix()];
          Severity: Minor
          Found in src/index.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

          Avoid too many return statements within this function.
          Open

            return fillVal;
          Severity: Major
          Found in src/index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return false;
            Severity: Major
            Found in src/index.js - About 30 mins to fix

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

              function getTagColor(currTag, parents) {
                const defaultColor = 'black';
                const fillVal = currTag.attributes.fill;
                let color;
                const parentsLength = parents.length;
              Severity: Minor
              Found in src/index.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

                          if ('width' in tag.attributes) {
                            glyph.width = parseFloat(tag.attributes.width);
                          } else {
                            this.log(
                              `Glyph "${glyph.name}" has no width attribute, using current glyph horizontal bounds.`
              Severity: Major
              Found in src/index.js and 1 other location - About 2 hrs to fix
              src/index.js on lines 263..270

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

              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 ('height' in tag.attributes) {
                            glyph.height = parseFloat(tag.attributes.height);
                          } else {
                            this.log(
                              `Glyph "${glyph.name}" has no height attribute, using current glyph vertical bounds.`
              Severity: Major
              Found in src/index.js and 1 other location - About 2 hrs to fix
              src/index.js on lines 255..262

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

              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 (
                    this.glyphs.some(
                      (anotherGlyph) =>
                        anotherGlyph !== glyph && anotherGlyph.unicode === glyph.unicode
                    )
              Severity: Major
              Found in src/index.js and 1 other location - About 1 hr to fix
              src/index.js on lines 162..172

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

              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 (
                    this.glyphs.some(
                      (anotherGlyph) =>
                        anotherGlyph !== glyph && anotherGlyph.name === glyph.name
                    )
              Severity: Major
              Found in src/index.js and 1 other location - About 1 hr to fix
              src/index.js on lines 197..209

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

              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

                      } else if ('polyline' === tag.name && 'none' !== tag.attributes.fill) {
                        this.log(
                          `Found a polyline element in the icon "${glyph.name}" the result could be different than expected.`
                        );
                        glyph.paths.push(
              Severity: Major
              Found in src/index.js and 1 other location - About 1 hr to fix
              src/index.js on lines 281..312

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

              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

                      } else if ('line' === tag.name && 'none' !== tag.attributes.fill) {
                        this.log(
                          `Found a line element in the icon "${glyph.name}" the result could be different than expected.`
                        );
                        glyph.paths.push(
              Severity: Major
              Found in src/index.js and 1 other location - About 1 hr to fix
              src/index.js on lines 288..312

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

              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 (glyph.defaultHeight || this._options.usePathBounds) {
                        glyph.height = bounds.maxY - bounds.minY;
                      }
              Severity: Minor
              Found in src/index.js and 1 other location - About 35 mins to fix
              src/index.js on lines 363..365

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

                      if (glyph.defaultWidth || this._options.usePathBounds) {
                        glyph.width = bounds.maxX - bounds.minX;
                      }
              Severity: Minor
              Found in src/index.js and 1 other location - About 35 mins to fix
              src/index.js on lines 360..362

              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

              Parsing error: Invalid ecmaVersion.
              Open

              /* eslint-disable complexity,prefer-reflect,max-len,newline-after-var */
              Severity: Minor
              Found in src/index.js by eslint

              For more information visit Source: http://eslint.org/docs/rules/

              There are no issues that match your filters.

              Category
              Status