Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

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

import { timeToInt } from '@peertube/peertube-core-utils'
import { VideoView, VideoViewEvent } from '@peertube/peertube-models'
import { logger } from '@root-helpers/logger'
import { isIOS, isMobile, isSafari } from '@root-helpers/web-browser'
import debug from 'debug'
Severity: Minor
Found in client/src/assets/player/shared/peertube/peertube-plugin.ts - About 7 hrs to fix

    File config-command.ts has 464 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { About, ActorImageType, ActorImageType_Type, CustomConfig, HttpStatusCode, ServerConfig } from '@peertube/peertube-models'
    import { DeepPartial } from '@peertube/peertube-typescript-utils'
    import merge from 'lodash-es/merge.js'
    import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command.js'
    
    
    Severity: Minor
    Found in packages/server-commands/src/server/config-command.ts - About 7 hrs to fix

      File videos.ts has 458 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { arrayify } from '@peertube/peertube-core-utils'
      import { HttpStatusCode, ServerErrorCode, UserRight, VideoState } from '@peertube/peertube-models'
      import { Redis } from '@server/lib/redis.js'
      import { buildUploadXFile, safeUploadXCleanup } from '@server/lib/uploadx.js'
      import { getServerActor } from '@server/models/application/application.js'
      Severity: Minor
      Found in server/core/middlewares/validators/videos/videos.ts - About 7 hrs to fix

        File job-queue.ts has 456 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { pick, timeoutPromise } from '@peertube/peertube-core-utils'
        import {
          ActivitypubFollowPayload,
          ActivitypubHttpBroadcastPayload,
          ActivitypubHttpFetcherPayload,
        Severity: Minor
        Found in server/core/lib/job-queue/job-queue.ts - About 6 hrs to fix

          VideosIdListQueryBuilder has 48 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class VideosIdListQueryBuilder extends AbstractRunQuery {
            protected replacements: any = {}
          
            private attributes: string[]
            private joins: string[] = []
          Severity: Minor
          Found in server/core/models/video/sql/video/videos-id-list-query-builder.ts - About 6 hrs to fix

            File client.ts has 443 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import {
              HttpStatusCode,
              VideoChaptersObject,
              VideoCommentObject,
              VideoPlaylistPrivacy,
            Severity: Minor
            Found in server/core/controllers/activitypub/client.ts - About 6 hrs to fix

              File account.ts has 435 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { Account, AccountSummary, VideoPrivacy } from '@peertube/peertube-models'
              import { ModelCache } from '@server/models/shared/model-cache.js'
              import { FindOptions, IncludeOptions, Includeable, Op, Transaction, WhereOptions, literal } from 'sequelize'
              import {
                AfterDestroy,
              Severity: Minor
              Found in server/core/models/account/account.ts - About 6 hrs to fix

                File edit-custom-config.component.ts has 435 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { NgFor, NgIf } from '@angular/common'
                import { Component, OnInit } from '@angular/core'
                import { FormsModule, ReactiveFormsModule } from '@angular/forms'
                import { ActivatedRoute, Router } from '@angular/router'
                import { ConfigService } from '@app/+admin/config/shared/config.service'

                  File config.ts has 432 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { About, ActorImageType, ActorImageType_Type, CustomConfig, HttpStatusCode, UserRight } from '@peertube/peertube-models'
                  import { createReqFiles } from '@server/helpers/express-utils.js'
                  import { MIMETYPES } from '@server/initializers/constants.js'
                  import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '@server/lib/local-actor.js'
                  import { ServerConfigManager } from '@server/lib/server-config-manager.js'
                  Severity: Minor
                  Found in server/core/controllers/api/config.ts - About 6 hrs to fix

                    File abuse-list-table.component.ts has 423 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import debug from 'debug'
                    import { SortMeta, SharedModule } from 'primeng/api'
                    import { Component, Input, OnInit, ViewChild } from '@angular/core'
                    import { ActivatedRoute, Router } from '@angular/router'
                    import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core'
                    Severity: Minor
                    Found in client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts - About 6 hrs to fix

                      File muxing-session.ts has 422 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import { wait } from '@peertube/peertube-core-utils'
                      import {
                        FileStorage,
                        LiveVideoError,
                        VideoFileFormatFlag,
                      Severity: Minor
                      Found in server/core/lib/live/shared/muxing-session.ts - About 6 hrs to fix

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

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

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

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

                            VideosCommand has 44 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            export class VideosCommand extends AbstractCommand {
                            
                              getCategories (options: OverrideCommandOptions = {}) {
                                const path = '/api/v1/videos/categories'
                            
                            
                            Severity: Minor
                            Found in packages/server-commands/src/videos/videos-command.ts - About 6 hrs to fix

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

                              export function sanitizeAndCheckVideoTorrentObject (video: VideoObject) {
                                if (!video || video.type !== 'Video') return false
                              
                                const fail = (field: string) => {
                                  logger.debug(`Video field is not valid to PeerTube: ${field}`, { video })
                              Severity: Minor
                              Found in server/core/helpers/custom-validators/activitypub/videos.ts - About 5 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

                              VideoWatchComponent has 43 functions (exceeds 20 allowed). Consider refactoring.
                              Open

                              @Component({
                                selector: 'my-video-watch',
                                templateUrl: './video-watch.component.html',
                                styleUrls: [ './video-watch.component.scss' ],
                                standalone: true,
                              Severity: Minor
                              Found in client/src/app/+videos/+video-watch/video-watch.component.ts - About 5 hrs to fix

                                File peertube-player.ts has 409 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import './shared/context-menu'
                                import './shared/upnext/end-card'
                                import './shared/upnext/upnext-plugin'
                                import './shared/stats/stats-card'
                                import './shared/stats/stats-plugin'
                                Severity: Minor
                                Found in client/src/assets/player/peertube-player.ts - About 5 hrs to fix

                                  Function buildIdsListQuery has 143 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    private buildIdsListQuery (options: BuildVideosListQueryOptions) {
                                      this.attributes = options.attributes || [ '"video"."id"' ]
                                  
                                      if (options.group) this.group = options.group
                                      if (options.having) this.having = options.having
                                  Severity: Major
                                  Found in server/core/models/video/sql/video/videos-id-list-query-builder.ts - About 5 hrs to fix

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

                                    async function run () {
                                      console.log('Preparing server...')
                                    
                                      await prepare()
                                    
                                    
                                    Severity: Major
                                    Found in scripts/benchmark.ts - About 5 hrs to fix

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

                                      import { NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common'
                                      import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, booleanAttribute } from '@angular/core'
                                      import { ActivatedRoute, RouterLink, RouterLinkActive } from '@angular/router'
                                      import {
                                        AuthService,
                                      Severity: Minor
                                      Found in client/src/app/shared/shared-video-miniature/videos-list.component.ts - About 5 hrs to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language