Showing 22 of 43 total issues
File xml-sugar.ts
has 548 lines of code (exceeds 250 allowed). Consider refactoring. Open
"use strict";
import * as detectNode from "detect-node";
import * as xmldom from "xmldom";
XMLSugar
has 55 functions (exceeds 20 allowed). Consider refactoring. Open
export default class XMLSugar {
private static encode(str: string): string {
if (!str) {
return str;
}
Function setEnvironment
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public setEnvironment(value: Environment, platform?: Platform) {
const names = platform ? [platform] : ["android", "ios"];
for (const name of names) {
let info: any;
- 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 formatXml
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static formatXml(xml: string): string {
const reg: RegExp = /(>)\s*(<)(\/*)/g;
const wsexp: RegExp = / *(.*) +\n/g;
const contexp: RegExp = /(<.+>)(.+\n)/g;
xml = xml.replace(reg, "$1\n$2$3").replace(wsexp, "$1\n").replace(contexp, "$1\n$2");
- 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 formatXml
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static formatXml(xml: string): string {
const reg: RegExp = /(>)\s*(<)(\/*)/g;
const wsexp: RegExp = / *(.*) +\n/g;
const contexp: RegExp = /(<.+>)(.+\n)/g;
xml = xml.replace(reg, "$1\n$2$3").replace(wsexp, "$1\n").replace(contexp, "$1\n$2");
Function getEnvironment
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public getEnvironment(platform?: Platform): Environment {
if (!platform) {
const environments = [this.getEnvironment(Platform.IOS), this.getEnvironment(Platform.Android)];
for (let j = 1; j < environments.length; ++j) {
if (environments[j] !== environments[j - 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 matchesFilter
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static matchesFilter(sugar: XMLSugar, node: Element, filter: any) {
const parent = node.parentNode as Element;
if (filter.parent) {
if (parent.getAttribute && parent.getAttribute("name") !== filter.parent) {
return false;
- 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 removeNode
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static removeNode(sugar: XMLSugar, filter: any) {
const node = XMLDOM.findNode(sugar, filter);
if (node && node.parentNode) {
const parent = node.parentNode as Element;
parent.removeChild(node);
- 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 replaceOldPluginSyntax
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static replaceOldPluginSyntax(doc: Document): Document {
const plugins = Array.prototype.slice.call(doc.getElementsByTagNameNS(cocoonNS, "plugin"));
for (const plugin of plugins) {
const pluginEle = doc.createElementNS(null, "plugin");
- 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 replaceOldPlatformSyntax
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private static replaceOldPlatformSyntax(doc: Document): Document {
const platforms = Array.prototype.slice.call(doc.getElementsByTagNameNS(cocoonNS, "platform"));
for (const platform of platforms) {
const platformEle: Element = doc.createElementNS(null, "platform");
- 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 updateOrAddNode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static updateOrAddNode(sugar: XMLSugar, filter: any, data: any) {
let found = XMLDOM.findNode(sugar, filter);
if (!found) {
const parent = XMLDOM.parentNodeForPlatform(sugar, filter.parent);
found = sugar.doc.createElementNS(null, filter.tag);
- 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 replaceOldPlatformSyntax
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static replaceOldPlatformSyntax(doc: Document): Document {
const platforms = Array.prototype.slice.call(doc.getElementsByTagNameNS(cocoonNS, "platform"));
for (const platform of platforms) {
const platformEle: Element = doc.createElementNS(null, "platform");
Function setEnvironment
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public setEnvironment(value: Environment, platform?: Platform) {
const names = platform ? [platform] : ["android", "ios"];
for (const name of names) {
let info: any;
Function setBundleId
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public setBundleId(value: string, platform?: Platform) {
if (platform) {
const name = BundleIdAlias[platform];
if (name) {
if (value) {
- 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 getVersionCode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public getVersionCode(platform?: Platform, fallback: boolean = true): string {
if (platform) {
const name = VersionCodeAlias[platform];
if (name) {
const version = this.root.getAttribute(name);
- 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 addPluginVariable
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public addPluginVariable(pluginName: string, varName: string, varValue: string) {
this.addPlugin(pluginName);
const plugin = this.findPlugin(pluginName);
if (plugin) {
const nodes = Array.prototype.slice.call(plugin.childNodes);
- 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
Avoid deeply nested control flow statements. Open
if (!info) {
continue;
}
Function setVersionCode
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public setVersionCode(value: string, platform?: Platform) {
if (platform) {
const name = VersionCodeAlias[platform];
if (name) {
if (value) {
- 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 setVersion
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public setVersion(value: string, platform?: Platform) {
if (platform) {
const name = platform + "-version";
if (name) {
if (value) {
- 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 findPluginVariable
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public findPluginVariable(pluginName: string, varName: string): string {
const plugin = this.findPlugin(pluginName);
let result: string;
if (plugin) {
const nodes = Array.prototype.slice.call(plugin.childNodes);
- 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"