Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function buildAvailableUrl has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  private buildAvailableUrl (obj: any) {
    const urls: string[] = []

    if (obj.url) urls.push(obj.url)
    if (obj.urls) {
Severity: Minor
Found in server/core/helpers/youtube-dl/youtube-dl-info-builder.ts - About 2 hrs 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 getLiveTranscodingCommand has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  async getLiveTranscodingCommand (options: LiveTranscodingOptions) {
    this.commandWrapper.debugLog('Building live transcoding command', options)

    const {
      inputUrl,
Severity: Minor
Found in packages/ffmpeg/src/ffmpeg-live.ts - About 2 hrs 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

File video-pre-import.ts has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  ThumbnailType,
  ThumbnailType_Type,
  VideoImportCreate,
  VideoImportPayload,
Severity: Minor
Found in server/core/lib/video-pre-import.ts - About 2 hrs to fix

    Function run has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async run (configOverrideArg?: any, options: RunServerOptions = {}) {
        // These actions are async so we need to be sure that they have both been done
        const serverRunString = {
          'HTTP server listening': false
        }
    Severity: Major
    Found in packages/server-commands/src/server/server.ts - About 2 hrs to fix

      Function levenshteinDistance has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function levenshteinDistance (a: string, b: string): number {
        if (a === b) {
          return 0
        }
      
      
      Severity: Major
      Found in packages/transcription-devtools/src/levenshtein.ts - About 2 hrs to fix

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

          constructor (player: videojs.Player, private readonly options: PeerTubePluginOptions) {
            super(player)
        
            this.menuOpened = false
            this.mouseInControlBar = false
        Severity: Major
        Found in client/src/assets/player/shared/peertube/peertube-plugin.ts - About 2 hrs to fix

          File videos-redundancy-scheduler.ts has 285 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { move } from 'fs-extra/esm'
          import { join } from 'path'
          import { getServerActor } from '@server/models/application/application.js'
          import { VideoModel } from '@server/models/video/video.js'
          import {
          Severity: Minor
          Found in server/core/lib/schedulers/videos-redundancy-scheduler.ts - About 2 hrs to fix

            Function createEl has 71 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              createEl () {
                const div = videojs.dom.createEl('div', { className: 'vjs-peertube' })
                const subDivP2P = videojs.dom.createEl('div', {
                  className: 'vjs-peertube-hidden' // Hide the stats before we get the info
                }) as HTMLDivElement
            Severity: Major
            Found in client/src/assets/player/shared/control-bar/p2p-info-button.ts - About 2 hrs to fix

              VideoModelBuilder has 25 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export class VideoModelBuilder {
                private videosMemo: { [ id: number ]: VideoModel }
                private videoStreamingPlaylistMemo: { [ id: number ]: VideoStreamingPlaylistModel }
                private videoFileMemo: { [ id: number ]: VideoFileModel }
              
              
              Severity: Minor
              Found in server/core/models/video/sql/video/shared/video-model-builder.ts - About 2 hrs to fix

                MuxingSession has 25 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class MuxingSession extends EventEmitter {
                
                  private transcodingWrapper: AbstractTranscodingWrapper
                
                  private readonly context: any
                Severity: Minor
                Found in server/core/lib/live/shared/muxing-session.ts - About 2 hrs to fix

                  JobQueue has 25 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class JobQueue {
                  
                    private static instance: JobQueue
                  
                    private workers: { [id in JobType]?: Worker } = {}
                  Severity: Minor
                  Found in server/core/lib/job-queue/job-queue.ts - About 2 hrs to fix

                    Function videoModelToActivityPubObject has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
                      const language = video.language
                        ? { identifier: video.language, name: getLanguageLabel(video.language) }
                        : undefined
                    
                    
                    Severity: Major
                    Found in server/core/models/video/formatter/video-activity-pub-format.ts - About 2 hrs to fix

                      Function definePluginsProgram has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function definePluginsProgram () {
                        const program = new Command()
                      
                        program
                          .name('plugins')
                      Severity: Major
                      Found in apps/peertube-cli/src/peertube-plugins.ts - About 2 hrs to fix

                        Function process has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          process () {
                            const job = this.options.job
                            const payload = job.payload
                        
                            return new Promise<void>(async (res, rej) => {
                        Severity: Major
                        Found in apps/peertube-runner/src/server/process/shared/process-live.ts - About 2 hrs to fix

                          File menu.component.ts has 282 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { CommonModule, ViewportScroller } from '@angular/common'
                          import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
                          import { Router, RouterLink, RouterLinkActive } from '@angular/router'
                          import {
                            AuthService,
                          Severity: Minor
                          Found in client/src/app/menu/menu.component.ts - About 2 hrs to fix

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

                              constructor (
                                private userNotificationService: UserNotificationService,
                                private serverService: ServerService,
                                private notifier: Notifier
                              ) {

                              Function buildPeerTubeHelpers has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                private buildPeerTubeHelpers (pluginInfo: PluginInfo): RegisterClientHelpers {
                                  const { plugin } = pluginInfo
                                  const npmName = pluginInfo.plugin.npmName
                              
                                  return {
                              Severity: Major
                              Found in client/src/app/core/plugins/plugin.service.ts - About 2 hrs to fix

                                Function waitJobs has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                async function waitJobs (
                                  serversArg: PeerTubeServer[] | PeerTubeServer,
                                  options: {
                                    skipDelayed?: boolean // default false
                                    runnerJobs?: boolean // default false
                                Severity: Major
                                Found in packages/server-commands/src/server/jobs.ts - About 2 hrs to fix

                                  Function checkObjectStorageConfig has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  function checkObjectStorageConfig () {
                                    if (CONFIG.OBJECT_STORAGE.ENABLED !== true) return
                                  
                                    if (!CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME) {
                                      throw new Error('videos_bucket should be set when object storage support is enabled.')
                                  Severity: Minor
                                  Found in server/core/initializers/checker-after-init.ts - About 2 hrs 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 checkLatestPluginsVersion has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    private async checkLatestPluginsVersion () {
                                      if (CONFIG.PLUGINS.INDEX.ENABLED === false) return
                                  
                                      logger.info('Checking latest plugins version.')
                                  
                                  
                                  Severity: Minor
                                  Found in server/core/lib/schedulers/plugins-check-scheduler.ts - About 2 hrs 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