translation/angular

View on GitHub

Showing 11 of 19 total issues

Base has 37 functions (exceeds 20 allowed). Consider refactoring.
Open

class Base {
  constructor(configFile) {
    this.configFile = configFile || 'tio.config.json' // default config file
  }

Severity: Minor
Found in src/calls/base.js - About 4 hrs to fix

    File base.js has 313 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const Interpolation = require('../utils/interpolation')
    
    const fs                        = require('fs')
    const path                      = require('path')
    const { XMLParser, XMLBuilder } = require('fast-xml-parser')
    Severity: Minor
    Found in src/calls/base.js - About 3 hrs to fix

      Function substitution has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        static substitution(extraction, existingSubstitutions) {
          let substitution, name, number
      
          if (extraction.includes('id="INTERPOLATION_') && ! extraction.includes('equiv-text=')) {        // {x2}, {x3}, ... // Interpolations in HTML templates
            number       = parseInt(extraction.split('id="INTERPOLATION_', 2)[1].split('"', 2)[0]) + 1
      Severity: Minor
      Found in src/utils/interpolation.js - 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

      Function run has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        run() {
          console.log("\n๐Ÿ Starting Translation.io Init process, please wait ๐Ÿ")
      
          if (! this.validateConfig('Init')) {
            return false
      Severity: Major
      Found in src/calls/init.js - About 2 hrs to fix

        Function substitution has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static substitution(extraction, existingSubstitutions) {
            let substitution, name, number
        
            if (extraction.includes('id="INTERPOLATION_') && ! extraction.includes('equiv-text=')) {        // {x2}, {x3}, ... // Interpolations in HTML templates
              number       = parseInt(extraction.split('id="INTERPOLATION_', 2)[1].split('"', 2)[0]) + 1
        Severity: Minor
        Found in src/utils/interpolation.js - About 1 hr to fix

          Function run has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            run() {
              console.log("\n๐Ÿ Starting Translation.io Sync process, please wait ๐Ÿ")
          
              if (! this.validateConfig('Sync')) {
                return false
          Severity: Minor
          Found in src/calls/sync.js - About 1 hr to fix

            Function validateConfig has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              validateConfig(action) {
                let valid = true
            
                try {
                  this.options()
            Severity: Minor
            Found in src/calls/base.js - About 1 hr to fix

              Function angularIdToHtmlTag has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                static angularIdToHtmlTag(id) {
                  return {
                    'LINK':               'a',
                    'BOLD_TEXT':          'b',
                    'EMPHASISED_TEXT':    'em',
              Severity: Minor
              Found in src/utils/html-tag-extraction.js - About 1 hr to fix

                Function validateConfig has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  validateConfig(action) {
                    let valid = true
                
                    try {
                      this.options()
                Severity: Minor
                Found in src/calls/base.js - About 55 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 xmlUnitContext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  xmlUnitContext(xmlUnit) {
                    const notes       = this.xmlUnitNotes(xmlUnit)
                    const id          = xmlUnit['@_id']
                    const contextNote = notes.find(note => note['@_from'] === 'meaning')
                    const isCustomId  = (id) => !/^\d+$|^\w{40}$/.test(id) // to separate generated IDs with manual IDs
                Severity: Minor
                Found in src/calls/base.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 flattenArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  flattenArray(array, depth = 1, stack = []) {
                    for (const unit of array) {
                      if (Array.isArray(unit) && depth > 0) {
                        this.flattenArray(unit, depth - 1, stack);
                      } else {
                Severity: Minor
                Found in src/calls/base.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