Function waitForElement
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export function waitForElement(config: StringConfig, callback: (element: ElementConfig) => void) {
const { el, err } = findMediaElement(config.video);
if (err) {
LOG.info(`${err}. Waiting for element to be added to the DOM.`);
}
- 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 findMediaElementChild
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function findMediaElementChild(el: Element): SearchResult {
for (let tag of ['VIDEO', 'AUDIO']) {
let descendentTags = el.getElementsByTagName(tag);
if (descendentTags.length === 1) {
const el = descendentTags[0];
- 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 findMediaElementChild(el);
Function findMediaElement
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function findMediaElement(id: string): SearchResult {
let el: HTMLElement | null = document.getElementById(id);
if (!el) return { err: SEARCH_ERROR.NOT_FOUND };
if (isHtmlAudioElement(el)) return { el };
- 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"