Showing 33 of 201 total issues
Function inputs
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const inputs = () => {
// capitalization is only for presentation purpose on the knob
const options = Object.keys(svgs)
.filter(key => key !== 'BBC_BLOCKS')
.map(key => key.charAt(0).toUpperCase() + key.slice(1));
Function ordinal
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
ordinal: function (number) {
var b = number % 10,
output =
~~((number % 100) / 10) === 1
? 'th'
- 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 getBrand
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getBrand = () => {
const {
productInput,
serviceLocalisedNameInput,
svgHeightInput,
Function inputs
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const inputs = (service = 'news') => {
const options = Object.keys(svgs).filter(key => key !== 'BBC_BLOCKS');
const svgChoice = select('Service SVG', options, service).toLowerCase();
const productInput = text('Product', 'BBC News');
const serviceLocalisedNameInput = text('Localised service name', 'Yoruba');
Function childrenFallback
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const childrenFallback = (
item,
dir,
columnsGroup,
marginsGroup,
- 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 Grid
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
(
{
children,
startOffset: gridStartOffset, // alias this prop to prevent it rendering as an element attribute e.g. <div startoffset="[object Object]">
...otherProps
- 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 too many return
statements within this function. Open
return convertToBlocks(node, [...attributes, styleAttribute]);
Avoid too many return
statements within this function. Open
return {
type: node.name,
model: {
text: getTextFromChildBlocks(childBlocks),
blocks: childBlocks,
Function xmlNodeToBlock
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const xmlNodeToBlock = (node, attributes) => {
if (!is(Object, node)) return undefined;
if (node.type === 'text') {
return fragment(node.text, attributes);
- 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 mockEventListener
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const mockEventListener = mockedEvent => {
const originalAddEventListener = window.addEventListener;
const originalRemoveEventListener = window.removeEventListener;
window.addEventListener = jest.fn((event, cb) => {
if (event !== mockedEvent) {
- 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 exports
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
module.exports = name => {
let packageVersions = [];
if (!checkPackage(name)) return '-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 convertToBlocks
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const convertToBlocks = (node, attributes = []) =>
pathOr([], ['children'], node).reduce((acc, childNode) => {
if (isXmlNodeSupported(childNode, attributes)) {
return handleSupportedNodes(childNode, attributes, acc);
}
- 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 mockEventListener
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const mockEventListener = mockedEvent => {
const originalAddEventListener = window.addEventListener;
const originalRemoveEventListener = window.removeEventListener;
window.addEventListener = jest.fn((event, cb) => {
if (event !== mockedEvent) {
- 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"