Chocobozzz/PeerTube

View on GitHub
client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts

Summary

Maintainability
C
1 day
Test Coverage

File hls-plugin.ts has 365 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Thanks https://github.com/streamroot/videojs-hlsjs-plugin
// We duplicated this plugin to choose the hls.js version we want, because streamroot only provide a bundled file

import { logger } from '@root-helpers/logger'
import Hlsjs, { ErrorData, Level, LevelSwitchingData, ManifestParsedData } from 'hls.js'
Severity: Minor
Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 4 hrs to fix

    Function initialize has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private initialize () {
        this.liveEnded = false
    
        this.buildBaseConfig()
    
    
    Severity: Minor
    Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 1 hr to fix

      Function _notifyVideoQualities has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private _notifyVideoQualities () {
          if (!this.metadata) return
      
          const resolutions: PeerTubeResolution[] = []
      
      
      Severity: Minor
      Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 1 hr to fix

        Function constructor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor (vjs: typeof videojs, source: videojs.Tech.SourceObject, tech: videojs.Tech) {
            this.vjs = vjs
            this.source = source
        
            this.tech = tech;
        Severity: Minor
        Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 1 hr to fix

          Function registerSourceHandler has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const registerSourceHandler = function (vjs: typeof videojs) {
            if (!Hlsjs.isSupported()) {
              logger.info('Hls.js is not supported in this browser.')
              return
            }
          Severity: Minor
          Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 1 hr to fix

            Function registerSourceHandler has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            const registerSourceHandler = function (vjs: typeof videojs) {
              if (!Hlsjs.isSupported()) {
                logger.info('Hls.js is not supported in this browser.')
                return
              }
            Severity: Minor
            Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 55 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 _onError has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              private _onError (_event: any, data: ErrorData) {
                const error: { message: string, code?: number } = {
                  message: `HLS.js error: ${data.type} - fatal: ${data.fatal} - ${data.details}`
                }
            
            
            Severity: Minor
            Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 45 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

            There are no issues that match your filters.

            Category
            Status