Chocobozzz/PeerTube

View on GitHub

Showing 1,188 of 3,041 total issues

PluginManager has 40 functions (exceeds 20 allowed). Consider refactoring.
Open

export class PluginManager implements ServerHook {

  private static instance: PluginManager

  private registeredPlugins: { [name: string]: RegisteredPlugin } = {}
Severity: Minor
Found in server/core/lib/plugins/plugin-manager.ts - About 5 hrs to fix

    File server.ts has 385 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { ChildProcess, fork } from 'child_process'
    import { copy } from 'fs-extra/esm'
    import { join } from 'path'
    import { randomInt } from '@peertube/peertube-core-utils'
    import { Video, VideoChannel, VideoChannelSync, VideoCreateResult, VideoDetails } from '@peertube/peertube-models'
    Severity: Minor
    Found in packages/server-commands/src/server/server.ts - About 5 hrs to fix

      ConfigCommand has 39 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class ConfigCommand extends AbstractCommand {
      
        static getCustomConfigResolutions (enabled: boolean, with0p = false) {
          return {
            '0p': enabled && with0p,
      Severity: Minor
      Found in packages/server-commands/src/server/config-command.ts - About 5 hrs to fix

        File server-config-manager.ts has 372 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import {
          HTMLServerConfig,
          RegisteredExternalAuthConfig,
          RegisteredIdAndPassAuthConfig,
          ServerConfig,
        Severity: Minor
        Found in server/core/lib/server-config-manager.ts - About 4 hrs to fix

          Function buildActions has 123 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private buildActions () {
              this.videoActions = [
                [
                  {
                    label: $localize`Save to playlist`,

            VideoCommentModel has 37 functions (exceeds 20 allowed). Consider refactoring.
            Open

            @Scopes(() => ({
              [ScopeNames.WITH_ACCOUNT]: {
                include: [
                  {
                    model: AccountModel
            Severity: Minor
            Found in server/core/models/video/video-comment.ts - About 4 hrs to fix

              File video-playlist.ts has 368 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { forceNumber } from '@peertube/peertube-core-utils'
              import {
                HttpStatusCode,
                VideoPlaylistCreate,
                VideoPlaylistCreateResult,
              Severity: Minor
              Found in server/core/controllers/api/video-playlist.ts - About 4 hrs to fix

                File videos-list.component.ts has 366 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import * as debug from 'debug'
                import { fromEvent, Observable, Subject, Subscription } from 'rxjs'
                import { concatMap, debounceTime, map, switchMap } from 'rxjs/operators'
                import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core'
                import { ActivatedRoute, RouterLinkActive, RouterLink } from '@angular/router'
                Severity: Minor
                Found in client/src/app/shared/shared-video-miniature/videos-list.component.ts - About 4 hrs to fix

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

                  import express from 'express'
                  import {
                    ActorImageType,
                    HttpStatusCode,
                    VideoChannelCreate,
                  Severity: Minor
                  Found in server/core/controllers/api/video-channel.ts - About 4 hrs to fix

                    Function getZanataContributors has 119 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function getZanataContributors () {
                      return [
                        { username: 'abdhessuk', name: 'Abd Hessuk' },
                        { username: 'abidin24', name: 'abidin toumi' },
                        { username: 'aditoo', name: 'Lorem Ipsum' },
                    Severity: Major
                    Found in scripts/generate-code-contributors.ts - About 4 hrs to fix

                      Function buildPeerTubePlayerLoadOptions has 118 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        private buildPeerTubePlayerLoadOptions (options: {
                          video: VideoDetails
                          liveVideo: LiveVideo
                          videoCaptions: VideoCaption[]
                          videoChapters: VideoChapter[]
                      Severity: Major
                      Found in client/src/app/+videos/+video-watch/video-watch.component.ts - About 4 hrs to fix

                        File player-options-builder.ts has 362 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { peertubeTranslate } from '@peertube/peertube-core-utils'
                        import {
                          HTMLServerConfig,
                          LiveVideo,
                          Storyboard,
                        Severity: Minor
                        Found in client/src/standalone/videos/shared/player-options-builder.ts - About 4 hrs to fix

                          Function sanitizeAndCheckVideoTorrentObject has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function sanitizeAndCheckVideoTorrentObject (video: VideoObject) {
                            if (!video || video.type !== 'Video') return false
                          
                            if (!setValidRemoteTags(video)) {
                              logger.debug('Video has invalid tags', { video })
                          Severity: Minor
                          Found in server/core/helpers/custom-validators/activitypub/videos.ts - About 4 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

                          VideoService has 35 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          @Injectable()
                          export class VideoService {
                            static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos'
                            static BASE_FEEDS_URL = environment.apiUrl + '/feeds/videos.'
                            static PODCAST_FEEDS_URL = environment.apiUrl + '/feeds/podcast/videos.xml'
                          Severity: Minor
                          Found in client/src/app/shared/shared-main/video/video.service.ts - About 4 hrs to fix

                            Function getSelect has 112 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              private getSelect () {
                                return `SELECT
                                  "UserNotificationModel"."id",
                                  "UserNotificationModel"."type",
                                  "UserNotificationModel"."read",
                            Severity: Major
                            Found in server/core/models/user/sql/user-notitication-list-query-builder.ts - About 4 hrs to fix

                              File user-moderation-dropdown.component.ts has 352 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core'
                              import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core'
                              import { BulkRemoveCommentsOfBody, User, UserRight } from '@peertube/peertube-models'
                              import { BlocklistService } from './blocklist.service'
                              import { BulkService } from './bulk.service'

                                Function reloadDataInternal has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  protected reloadDataInternal () {
                                    debugLogger('Loading data.')
                                
                                    const options = {
                                      pagination: this.pagination,
                                Severity: Minor
                                Found in client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts - About 4 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 checkMissedConfig has 107 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function checkMissedConfig () {
                                  const required = [ 'listen.port', 'listen.hostname',
                                    'webserver.https', 'webserver.hostname', 'webserver.port',
                                    'secrets.peertube',
                                    'trust_proxy',
                                Severity: Major
                                Found in server/core/initializers/checker-before-init.ts - About 4 hrs to fix

                                  Function getOverallStats has 107 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    static async getOverallStats (options: {
                                      video: MVideo
                                      startDate?: string
                                      endDate?: string
                                    }): Promise<VideoStatsOverall> {
                                  Severity: Major
                                  Found in server/core/models/view/local-video-viewer.ts - About 4 hrs to fix

                                    Function getOverallStats has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      static async getOverallStats (options: {
                                        video: MVideo
                                        startDate?: string
                                        endDate?: string
                                      }): Promise<VideoStatsOverall> {
                                    Severity: Minor
                                    Found in server/core/models/view/local-video-viewer.ts - About 4 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