Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function checkMissedConfig has 109 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

    VideoActionsDropdownComponent has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
      selector: 'my-video-actions-dropdown',
      templateUrl: './video-actions-dropdown.component.html',
      styleUrls: [ './video-actions-dropdown.component.scss' ],
      standalone: true,

      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 constructor has 107 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor (hash: UserNotificationServer, user: AuthUser) {
            this.id = hash.id
            this.type = hash.type
            this.read = hash.read
        
        
        Severity: Major
        Found in client/src/app/shared/shared-main/users/user-notification.model.ts - About 4 hrs to fix

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

            async addIntroOutro (options: BaseStudioOptions & {
              introOutroPath: string
          
              type: 'intro' | 'outro'
            }) {
          Severity: Major
          Found in packages/ffmpeg/src/ffmpeg-edition.ts - About 4 hrs to fix

            File embed.ts has 344 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import './embed.scss'
            import '../../assets/player/shared/dock/peertube-dock-component'
            import '../../assets/player/shared/dock/peertube-dock-plugin'
            import { PeerTubeServerError } from 'src/types'
            import videojs from 'video.js'
            Severity: Minor
            Found in client/src/standalone/videos/embed.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

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

              /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
              
              import { HttpStatusCode, HttpStatusCodeType } from '@peertube/peertube-models'
              import { buildAbsoluteFixturePath, getFileSize } from '@peertube/peertube-node-utils'
              import { expect } from 'chai'
              Severity: Minor
              Found in packages/server-commands/src/shared/abstract-command.ts - About 4 hrs to fix

                File redis.ts has 339 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { sha256 } from '@peertube/peertube-node-utils'
                import { exists } from '@server/helpers/custom-validators/misc.js'
                import { Redis as IoRedis, RedisOptions } from 'ioredis'
                import { logger, loggerTagsFactory } from '../helpers/logger.js'
                import { generateRandomString } from '../helpers/utils.js'
                Severity: Minor
                Found in server/core/lib/redis.ts - About 4 hrs to fix

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

                  import { AggregateOptions, Op, ScopeOptions, Sequelize, Transaction } from 'sequelize'
                  import {
                    AllowNull,
                    BelongsTo,
                    Column,
                  Severity: Minor
                  Found in server/core/models/video/video-playlist-element.ts - About 4 hrs to fix

                    VideoRedundancyModel has 32 functions (exceeds 20 allowed). Consider refactoring.
                    Open

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

                      Function buildAbuseListQuery has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function buildAbuseListQuery (options: BuildAbusesQueryOptions, type: 'count' | 'id') {
                        const whereAnd: string[] = []
                        const replacements: any = {}
                      
                        const joins = [
                      Severity: Major
                      Found in server/core/models/abuse/sql/abuse-query-builder.ts - About 3 hrs to fix

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

                        import express from 'express'
                        import { body, param, query, ValidationChain } from 'express-validator'
                        import { forceNumber } from '@peertube/peertube-core-utils'
                        import {
                          HttpStatusCode,
                        Severity: Minor
                        Found in server/core/middlewares/validators/videos/video-playlists.ts - About 3 hrs to fix

                          File video-model-builder.ts has 330 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { VideoInclude, VideoIncludeType } from '@peertube/peertube-models'
                          import { AccountBlocklistModel } from '@server/models/account/account-blocklist.js'
                          import { AccountModel } from '@server/models/account/account.js'
                          import { ActorImageModel } from '@server/models/actor/actor-image.js'
                          import { ActorModel } from '@server/models/actor/actor.js'
                          Severity: Minor
                          Found in server/core/models/video/sql/video/shared/video-model-builder.ts - About 3 hrs to fix

                            Function buildWhere has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              private buildWhere () {
                                let where: string[] = []
                            
                                if (this.options.videoId) {
                                  this.replacements.videoId = this.options.videoId

                              Function create has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                async create () {
                                  this.video = new VideoModel(
                                    await Hooks.wrapObject(this.buildVideo(this.videoAttributes, this.channel), this.videoAttributeResultHook)
                                  ) as MVideoFullLight
                              
                              
                              Severity: Major
                              Found in server/core/lib/local-video-creator.ts - About 3 hrs to fix

                                Function buildVideosFromRows has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  buildVideosFromRows (options: {
                                    rows: SQLRow[]
                                    include?: VideoIncludeType
                                    rowsWebVideoFiles?: SQLRow[]
                                    rowsStreamingPlaylist?: SQLRow[]
                                Severity: Minor
                                Found in server/core/models/video/sql/video/shared/video-model-builder.ts - About 3 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 fixCompacted has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function fixCompacted (original: any, compacted: any) {
                                  if (!original || !compacted) return
                                
                                  for (const [ k, v ] of Object.entries(original)) {
                                    if (k === '@context' || k === 'signature') continue
                                Severity: Minor
                                Found in server/core/helpers/peertube-jsonld.ts - About 3 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 buildPeerTubePlayerLoadOptions has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  private buildPeerTubePlayerLoadOptions (options: {
                                    video: VideoDetails
                                    liveVideo: LiveVideo
                                    videoCaptions: VideoCaption[]
                                    videoChapters: VideoChapter[]
                                Severity: Minor
                                Found in client/src/app/+videos/+video-watch/video-watch.component.ts - About 3 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 waitJobs has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                                Open

                                async function waitJobs (
                                  serversArg: PeerTubeServer[] | PeerTubeServer,
                                  options: {
                                    skipDelayed?: boolean // default false
                                    runnerJobs?: boolean // default false
                                Severity: Minor
                                Found in packages/server-commands/src/server/jobs.ts - About 3 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