Chocobozzz/PeerTube

View on GitHub

Showing 1,188 of 3,041 total issues

VideosIdListQueryBuilder has 47 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 peertube-plugin.ts has 437 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 6 hrs to fix

      Function exports has 159 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function () {
        const configuration = {
          entry: {
            'video-embed': './src/standalone/videos/embed.ts',
            'player': './src/standalone/embed-player-api/player.ts',
      Severity: Major
      Found in client/webpack/webpack.video-embed.js - About 6 hrs to fix

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

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

          Function sanitize has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
          Open

            protected sanitize (o: ImportObject) {
              if (!isVideoNameValid(o.name)) return undefined
              if (!isVideoDurationValid(o.duration + '')) return undefined
              if (!isVideoChannelUsernameValid(o.channel?.name)) return undefined
              if (!isVideoPrivacyValid(o.privacy)) return undefined
          Severity: Minor
          Found in server/core/lib/user-import-export/importers/videos-importer.ts - About 6 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 abuse-list-table.component.ts has 423 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import * as 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 edit-custom-config.component.ts has 422 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import omit from 'lodash-es/omit'
            import { forkJoin } from 'rxjs'
            import { SelectOptionsItem } from 'src/types/select-options-item.model'
            import { Component, OnInit } from '@angular/core'
            import { ActivatedRoute, Router } from '@angular/router'

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

              import express from 'express'
              import { remove, writeJSON } from 'fs-extra/esm'
              import snakeCase from 'lodash-es/snakeCase.js'
              import validator from 'validator'
              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 video-actions-dropdown.component.ts has 412 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { NgIf } from '@angular/common'
                import { Component, EventEmitter, Input, OnChanges, Output, ViewChild, booleanAttribute } from '@angular/core'
                import { AuthService, ConfirmService, Notifier, ScreenService, ServerService } from '@app/core'
                import { NgbDropdown, NgbDropdownAnchor, NgbDropdownMenu } from '@ng-bootstrap/ng-bootstrap'
                import { VideoCaption } from '@peertube/peertube-models'

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

                  import '@peertube/videojs-contextmenu'
                  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

                    File users.ts has 407 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import express from 'express'
                    import { body, param, query } from 'express-validator'
                    import { forceNumber } from '@peertube/peertube-core-utils'
                    import { HttpStatusCode, UserRight, UserRole } from '@peertube/peertube-models'
                    import { exists, isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
                    Severity: Minor
                    Found in server/core/middlewares/validators/users/users.ts - About 5 hrs to fix

                      VideoWatchComponent has 42 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

                        VideosCommand has 42 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 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

                            Function buildIdsListQuery has 140 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 generateNodeinfo has 139 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              async function generateNodeinfo (req: express.Request, res: express.Response) {
                                const { totalVideos } = await VideoModel.getStats()
                                const { totalLocalVideoComments } = await VideoCommentModel.getStats()
                                const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats()
                              
                              
                              Severity: Major
                              Found in server/core/controllers/misc.ts - About 5 hrs to fix

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

                                import { FindOptions, Includeable, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize'
                                import {
                                  AllowNull,
                                  BeforeDestroy,
                                  BelongsTo,
                                Severity: Minor
                                Found in server/core/models/account/account.ts - About 5 hrs to fix

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

                                  import { wait } from '@peertube/peertube-core-utils'
                                  import { FileStorage, LiveVideoError, VideoStreamingPlaylistType } from '@peertube/peertube-models'
                                  import { computeOutputFPS } from '@server/helpers/ffmpeg/index.js'
                                  import { LoggerTagsFn, logger, loggerTagsFactory } from '@server/helpers/logger.js'
                                  import { CONFIG } from '@server/initializers/config.js'
                                  Severity: Minor
                                  Found in server/core/lib/live/shared/muxing-session.ts - About 5 hrs to fix

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

                                    async function run () {
                                      await initDatabaseModels(true)
                                    
                                      const serverAccount = await getServerActor()
                                    
                                    
                                    Severity: Major
                                    Found in server/scripts/update-host.ts - About 5 hrs to fix

                                      File config-command.ts has 389 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 5 hrs to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language