Showing 12 of 18 total issues
File index.js
has 425 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global $ */
import './scss/index.scss';
import React from 'react';
import ReactDOM from 'react-dom/client';
Player
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
export default class Player {
constructor(elem) {
if (!elem) {
return;
}
Function rules
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
const rules = () => {
return [
{
test: /\.js$/,
include: /src/,
Function config
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const config = function(mode) {
let conf = {
mode,
entry: ['babel-polyfill','./src/index.js'],
module: {
Function createAVComponent
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
createAVComponent() {
this.$avcomponent = $('<section class="iiif-av-component" tabindex="0"></section>');
this.elem.append(this.$avcomponent);
let player = this;
Function SubtitleMenu
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export const SubtitleMenu = ({ tracks, player, configuredLanguage }: Props) => {
const refs : MenuItemRefs = {}
tracks.forEach((track) => {
refs[track.language] = React.createRef()
});
- 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 initLanguages
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
initLanguages(textTracks) {
// check if we have any texttracks
if (textTracks.length === 0) {
return;
}
Function files
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const files = function() {
return [
{
pattern: `./tests/spec/**/*.spec.js`, watched: true, type: 'module' },
'https://code.jquery.com/jquery-3.4.1.min.js',
Function itemSelectListener
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
itemSelectListener(data) {
if (this.handler === undefined) {
this.handler = this;
}
Function fetchTextResource
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
async function fetchTextResource(player, annotationResource, textResource, language, source, mediaItemLanguage) {
Function getLanguageForCanvasId
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
getLanguageForCanvasId() {
for (let i = 0; i < this.canvases.length; i++) {
if (this.canvasId === this.canvases[i].id) {
if (this.canvases[i].getContent()[0].__jsonld.body.language) {
return languages.find(lang => lang.code === this.canvases[i].getContent()[0].__jsonld.body.language).code;
- 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 getLanguageForMediaItem
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
getLanguageForMediaItem() {
for (let i = 0; i < this.canvases.length; i++) {
const canvasContent = this.canvases[i].getContent();
if (this.mediaItem === canvasContent[0].__jsonld.body.id) {
if (canvasContent[0].__jsonld.body.language) {
- 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"