ReCreateJS/txtjs

View on GitHub

Showing 340 of 340 total issues

Avoid deeply nested control flow statements.
Open

          if (this.center > this.length) {
            this.center = this.center - this.length;
          }
Severity: Major
Found in src/Path.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

              if (this.center > this.length) {
                this.center = this.center - this.length;
              }
    Severity: Major
    Found in src/Path.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (this.center > this.length) {
                  this.center = this.center - this.length;
                }
      Severity: Major
      Found in src/Path.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if (firstLine == false && this.lineHeight != null) {
                  currentLine.measuredHeight = this.lineHeight;
                } else {
                  currentLine.measuredHeight = vPosition;
                }
        Severity: Major
        Found in src/Text.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          for (let k = 0; k < pathLength; k++) {
                            if (target[path[k]] == undefined) {
                              target[path[k]] = {};
                            }
                            if (k == pathLength - 1) {
          Severity: Major
          Found in src/FontLoader.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if i.has_attr('horiz-adv-x') and i.has_attr('d'):
                                    out += '1|' + unicode_str + '|' + i['horiz-adv-x'] + '|' + i['d']  + '\n'
            
                                elif i.has_attr('d') and i.has_attr('horiz-adv-x') == False:
                                    out += '1|' + unicode_str + '|' + str( default ) + '|' + i['d']  + '\n'
            Severity: Major
            Found in tools/font_export/main.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if (this.align == PathAlign.Left) {
                          realStart = this.start;
                          position = realStart - distance;
                        } else if (this.align == PathAlign.Center) {
                          realStart = this.start - (this.realLength - characterLength) / 2;
              Severity: Major
              Found in src/Path.ts - About 45 mins to fix

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

                            if i.has_attr('id'):
                                out += '0|id|' + i['id'] + '\n'
                Severity: Major
                Found in tools/font_export/main.py and 13 other locations - About 45 mins to fix
                tools/font_export/main.py on lines 140..142
                tools/font_export/main.py on lines 161..162
                tools/font_export/main.py on lines 164..165
                tools/font_export/main.py on lines 167..168
                tools/font_export/main.py on lines 170..171
                tools/font_export/main.py on lines 173..174
                tools/font_export/main.py on lines 176..177
                tools/font_export/main.py on lines 179..180
                tools/font_export/main.py on lines 182..183
                tools/font_export/main.py on lines 185..186
                tools/font_export/main.py on lines 188..189
                tools/font_export/main.py on lines 191..192
                tools/font_export/main.py on lines 194..195

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

                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

                Avoid deeply nested control flow statements.
                Open

                          if (this.align == PathAlign.Left) {
                            realStart = this.start;
                          } else if (this.align == PathAlign.Center) {
                            realStart = this.start + (this.realLength - characterLength) / 2;
                          } else if (this.align == PathAlign.Right) {
                Severity: Major
                Found in src/Path.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                          if (this.lineHeight != null) {
                            lastHeight = currentLine.y + this.lineHeight;
                          } else {
                            lastHeight = currentLine.y + vPosition;
                          }
                  Severity: Major
                  Found in src/Text.ts - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if i.has_attr('glyph-name'):
                                            print( 'CHARS[ "' + unicode_str + '" ] = 1' )
                                        else:
                                            print( 'CHARS[ "' + unicode_str + '" ] = 1 ' )
                                        continue
                    Severity: Major
                    Found in tools/font_export/main.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                if (this.align == PathAlign.Left) {
                                  realStart = this.start;
                                  position = realStart + distance;
                                } else if (this.align == PathAlign.Center) {
                                  realStart = this.start + (this.realLength - characterLength) / 2;
                      Severity: Major
                      Found in src/Path.ts - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                if (i < len - 1) {
                                  vPosition = 0;
                                }
                        Severity: Major
                        Found in src/Text.ts - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                    if (position > this.length) {
                                      position = position - this.length;
                                    }
                          Severity: Major
                          Found in src/Path.ts - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if CHARS.has_key( unicode_str ) and CHARS[ unicode_str ] != 1:
                                                    unicode_str = CHARS[ unicode_str ]
                            
                            
                            Severity: Major
                            Found in tools/font_export/main.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                        if (this.align == PathAlign.Left) {
                                          realStart = this.start;
                                          position = realStart + distance;
                                        } else if (this.align == PathAlign.Center) {
                                          realStart = this.start + (this.realLength - characterLength) / 2;
                              Severity: Major
                              Found in src/Path.ts - About 45 mins to fix

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

                                  static update() {
                                    Accessibility.timeout = null;
                                    const data = Accessibility.data.slice(0);
                                    data.sort(function(a, b) {
                                      return a.accessibilityPriority - b.accessibilityPriority;
                                Severity: Minor
                                Found in src/Accessibility.ts - 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 deeply nested control flow statements.
                                Open

                                            if (
                                              char._font.ligatures[ligTarget.charAt(0)][ligTarget.charAt(1)][
                                                ligTarget.charAt(2)
                                              ]
                                            ) {
                                Severity: Major
                                Found in src/PathText.ts - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if i.has_attr('d') and i.has_attr('horiz-adv-x'):
                                                          out += '1|' + CHARS[ unicode_str ] + '|' + i['horiz-adv-x'] + '|' + i['d']  + '\n'
                                  
                                                      elif i.has_attr('d') and i.has_attr('horiz-adv-x') == False:
                                                          out += '1|' + CHARS[ unicode_str ] + '|' + str( default ) + '|' + i['d']  + '\n'
                                  Severity: Major
                                  Found in tools/font_export/main.py - About 45 mins to fix

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

                                      constructor(
                                        x1: number[],
                                        rx: number,
                                        ry: number,
                                        phiarg: number,
                                    Severity: Minor
                                    Found in src/SVGArc.ts - 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language