europeana/media-player

View on GitHub

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';
Severity: Minor
Found in src/components/player/index.js - About 6 hrs to fix

    Player has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Player {
      constructor(elem) {
        if (!elem) {
          return;
        }
    Severity: Minor
    Found in src/components/player/index.js - About 3 hrs to fix

      Function rules has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const rules = () => {
        return [
          {
            test: /\.js$/,
            include: /src/,
      Severity: Major
      Found in karma.conf.js - About 2 hrs to fix

        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: {
        Severity: Minor
        Found in webpack.config.js - About 1 hr to fix

          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;
          Severity: Minor
          Found in src/components/player/index.js - About 1 hr to fix

            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()
              }); 
            Severity: Minor
            Found in src/components/player/subtitleMenu.tsx - About 1 hr to fix

            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;
                }
            Severity: Minor
            Found in src/components/player/index.js - About 1 hr to fix

              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',
              Severity: Minor
              Found in karma.conf.js - About 1 hr to fix

                Function itemSelectListener has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  itemSelectListener(data) {
                    if (this.handler === undefined) {
                      this.handler = this;
                    }
                
                
                Severity: Minor
                Found in src/components/player/index.js - About 1 hr to fix

                  Function fetchTextResource has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  async function fetchTextResource(player, annotationResource, textResource, language, source, mediaItemLanguage) {
                  Severity: Minor
                  Found in src/components/player/transcriptionAnnotations.js - About 45 mins to fix

                    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;
                    Severity: Minor
                    Found in src/components/player/index.js - About 35 mins to fix

                    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) {
                    Severity: Minor
                    Found in src/components/player/index.js - About 35 mins to fix

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language