Chocobozzz/PeerTube

View on GitHub

Showing 1,230 of 3,155 total issues

Function create has 95 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 defineAuthProgram has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function defineAuthProgram () {
      const program = new Command()
        .name('auth')
        .description('Register your accounts on remote instances to use them with other commands')
    
    
    Severity: Major
    Found in apps/peertube-cli/src/peertube-auth.ts - About 3 hrs to fix

      File video-comment-list-query-builder.ts has 321 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { ActorImageType, VideoPrivacy } from '@peertube/peertube-models'
      import { AbstractRunQuery, ModelBuilder } from '@server/models/shared/index.js'
      import { Model, Sequelize, Transaction } from 'sequelize'
      import { createSafeIn, getSort, parseRowCountResult } from '../../../shared/index.js'
      import { VideoCommentTableAttributes } from './video-comment-table-attributes.js'

        File thumbnail.ts has 321 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { join } from 'path'
        import { ThumbnailType, ThumbnailType_Type } from '@peertube/peertube-models'
        import { generateImageFilename } from '../helpers/image-utils.js'
        import { CONFIG } from '../initializers/config.js'
        import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants.js'
        Severity: Minor
        Found in server/core/lib/thumbnail.ts - About 3 hrs to fix

          VideoStatsComponent has 30 functions (exceeds 20 allowed). Consider refactoring.
          Open

          @Component({
            templateUrl: './video-stats.component.html',
            styleUrls: [ './video-stats.component.scss' ],
            providers: [ NumberFormatterPipe ],
            standalone: true,
          Severity: Minor
          Found in client/src/app/+stats/video/video-stats.component.ts - About 3 hrs to fix

            Function buildAbuseListQuery has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

            function buildAbuseListQuery (options: BuildAbusesQueryOptions, type: 'count' | 'id') {
              const whereAnd: string[] = []
              const replacements: any = {}
            
              const joins = [
            Severity: Minor
            Found in server/core/models/abuse/sql/abuse-query-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 up has 89 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function up (utils: {
              transaction: Sequelize.Transaction
              queryInterface: Sequelize.QueryInterface
              sequelize: Sequelize.Sequelize
            }): Promise<void> {
            Severity: Major
            Found in server/core/initializers/migrations/0845-auto-tags.ts - About 3 hrs to fix

              File jobs.ts has 314 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import express, { UploadFiles } from 'express'
              import { retryTransactionWrapper } from '@server/helpers/database-utils.js'
              import { createReqFiles } from '@server/helpers/express-utils.js'
              import { logger, loggerTagsFactory } from '@server/helpers/logger.js'
              import { generateRunnerJobToken } from '@server/helpers/token-generator.js'
              Severity: Minor
              Found in server/core/controllers/api/runners/jobs.ts - About 3 hrs to fix

                Function up has 88 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function up (utils: {
                  transaction: Sequelize.Transaction
                  queryInterface: Sequelize.QueryInterface
                  sequelize: Sequelize.Sequelize
                  db: any
                Severity: Major
                Found in server/core/initializers/migrations/0595-remote-url.ts - About 3 hrs to fix

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

                  import { DatePipe, NgClass, NgFor, NgIf } from '@angular/common'
                  import { Component, OnInit, ViewChild } from '@angular/core'
                  import { ActivatedRoute, Router, RouterLink } from '@angular/router'
                  import { AuthService, ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
                  import { formatICU, getAbsoluteAPIUrl } from '@app/helpers'
                  Severity: Minor
                  Found in client/src/app/+admin/overview/videos/video-list.component.ts - About 3 hrs to fix

                    VideoAddToPlaylistComponent has 29 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    @Component({
                      selector: 'my-video-add-to-playlist',
                      styleUrls: [ './video-add-to-playlist.component.scss' ],
                      templateUrl: './video-add-to-playlist.component.html',
                      changeDetection: ChangeDetectionStrategy.OnPush,

                      File local-video-viewer.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import { QueryTypes } from 'sequelize'
                      import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, HasMany, IsUUID, Table } from 'sequelize-typescript'
                      import { getActivityStreamDuration } from '@server/lib/activitypub/activity.js'
                      import { buildGroupByAndBoundaries } from '@server/lib/timeserie.js'
                      import { MLocalVideoViewer, MLocalVideoViewerWithWatchSections, MVideo } from '@server/types/models/index.js'
                      Severity: Minor
                      Found in server/core/models/view/local-video-viewer.ts - About 3 hrs to fix

                        File video-update.component.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import debug from 'debug'
                        import { UploadState, UploadxService } from 'ngx-uploadx'
                        import { of, Subject, Subscription } from 'rxjs'
                        import { catchError, map, switchMap } from 'rxjs/operators'
                        import { SelectChannelItem } from 'src/types/select-options-item.model'
                        Severity: Minor
                        Found in client/src/app/+videos/+video-edit/video-update.component.ts - About 3 hrs to fix

                          File signup.e2e-spec.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { AdminConfigPage } from '../po/admin-config.po'
                          import { AdminRegistrationPage } from '../po/admin-registration.po'
                          import { LoginPage } from '../po/login.po'
                          import { SignupPage } from '../po/signup.po'
                          import {
                          Severity: Minor
                          Found in client/e2e/src/suites-local/signup.e2e-spec.ts - About 3 hrs to fix

                            Function listForApi has 86 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              static listForApi (options: {
                                start: number
                                count: number
                                sort: string
                                target: VideoRedundanciesTarget
                            Severity: Major
                            Found in server/core/models/redundancy/video-redundancy.ts - About 3 hrs to fix

                              Function processGenerateStoryboard has 86 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              async function processGenerateStoryboard (job: Job): Promise<void> {
                                const payload = job.data as GenerateStoryboardPayload
                                const lTags = lTagsBase(payload.videoUUID)
                              
                                logger.info('Processing generate storyboard of %s in job %s.', payload.videoUUID, job.id, lTags)
                              Severity: Major
                              Found in server/core/lib/job-queue/handlers/generate-storyboard.ts - About 3 hrs to fix

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

                                import { DatePipe, NgClass, NgIf } from '@angular/common'
                                import { Component, OnInit, ViewChild } from '@angular/core'
                                import { FormsModule } from '@angular/forms'
                                import { ActivatedRoute, Router, RouterLink } from '@angular/router'
                                import { AuthService, ConfirmService, LocalStorageService, Notifier, RestPagination, RestTable } from '@app/core'
                                Severity: Minor
                                Found in client/src/app/+admin/overview/users/user-list/user-list.component.ts - About 3 hrs to fix

                                  Function buildVideosFromRows has a Cognitive Complexity of 24 (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

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

                                  import { omit, pick } from '@peertube/peertube-core-utils'
                                  import {
                                    HttpStatusCode,
                                    MyUser,
                                    ResultList,
                                  Severity: Minor
                                  Found in packages/server-commands/src/users/users-command.ts - About 3 hrs to fix

                                    VideoEditComponent has 28 functions (exceeds 20 allowed). Consider refactoring.
                                    Open

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