Showing 4 of 6 total issues
Function getRawConfig
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getRawConfig(rawConfig: string): IRawConfig {
return splitByPipe(rawConfig).reduce(
(acc, part) => {
if (part.startsWith('format')) {
acc.format.push({
Function getNodeSelector
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
function getNodeSelector(node: Node): string[] {
if (node.type !== ElementType.Tag) return [];
if (!node.parent) return node instanceof Element ? [node.tagName] : [];
// nth-child selector index starts at 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 parseArrayConfig
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function parseArrayConfig(rawConfig: IRawArrayConfig): IArrayConfig {
const rawConfigItem = rawConfig[0];
if (!rawConfigItem) {
throw new Error(
Function getStyleProperty
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
function getStyleProperty(nodes: Node[], property: string) {
for (const node of nodes) {
const expressions = (getAttribute([node], 'style') || '')
.split(';')
.map(expression => expression.trim());
- 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"