europeana/media-player

View on GitHub

Showing 18 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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            if (canvasContent[0].__jsonld.body.language) {
              return languages.find(lang => lang.code === canvasContent[0].__jsonld.body.language).code;
            } else {
              return null;
            }
        Severity: Major
        Found in src/components/player/index.js and 1 other location - About 1 hr to fix
        src/components/player/index.js on lines 472..476

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                if (canvasContent[0].__jsonld.body.language) {
                  return languages.find(lang => lang.code === canvasContent[0].__jsonld.body.language).code;
                } else {
                  return null;
                }
        Severity: Major
        Found in src/components/player/index.js and 1 other location - About 1 hr to fix
        src/components/player/index.js on lines 484..488

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                resolve: {
                  extensions: ['.ts', '.tsx', '.js', '.json'],
                  alias: {
                    process: 'process/browser'
                  },
            Severity: Major
            Found in webpack.config.js and 1 other location - About 1 hr to fix
            karma.conf.js on lines 82..92

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

              return {
                extensions: ['.ts', '.tsx', '.js', '.json'],
                alias: {
                  process: 'process/browser'
                },
            Severity: Major
            Found in karma.conf.js and 1 other location - About 1 hr to fix
            webpack.config.js on lines 25..35

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            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

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                    return {
                      test: /\.[s]?css$/,
                      use: [
                        'style-loader',
                        { loader: 'css-loader', options: { sourceMap: true } },
                  Severity: Minor
                  Found in webpack.config.js and 1 other location - About 45 mins to fix
                  karma.conf.js on lines 117..124

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 50.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                      {
                        test: /\.[s]?css$/,
                        use: [
                          'style-loader',
                          { loader: 'css-loader', options: { sourceMap: true } },
                  Severity: Minor
                  Found in karma.conf.js and 1 other location - About 45 mins to fix
                  webpack.config.js on lines 124..131

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 50.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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