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
}
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')
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
- Read upRead up
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
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
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
Function validateConfig
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
validateConfig(action) {
let valid = true
try {
this.options()
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',
Function validateConfig
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
validateConfig(action) {
let valid = true
try {
this.options()
- Read upRead up
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
- Read upRead up
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 {
- Read upRead up
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"