client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts
File hls-plugin.ts
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
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'
Function initialize
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private initialize () {
this.liveEnded = false
this.buildBaseConfig()
Function _notifyVideoQualities
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private _notifyVideoQualities () {
if (!this.metadata) return
const resolutions: PeerTubeResolution[] = []
Function constructor
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor (vjs: typeof videojs, source: videojs.Tech.SourceObject, tech: videojs.Tech) {
this.vjs = vjs
this.source = source
this.tech = tech;
Function registerSourceHandler
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const registerSourceHandler = function (vjs: typeof videojs) {
if (!Hlsjs.isSupported()) {
logger.info('Hls.js is not supported in this browser.')
return
}
Function registerSourceHandler
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
const registerSourceHandler = function (vjs: typeof videojs) {
if (!Hlsjs.isSupported()) {
logger.info('Hls.js is not supported in this browser.')
return
}
- 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 _onError
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
private _onError (_event: any, data: ErrorData) {
const error: { message: string, code?: number } = {
message: `HLS.js error: ${data.type} - fatal: ${data.fatal} - ${data.details}`
}
- 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"