Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

UsersCommand has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

export class UsersCommand extends AbstractCommand {

  askResetPassword (options: OverrideCommandOptions & {
    email: string
  }) {
Severity: Minor
Found in packages/server-commands/src/users/users-command.ts - About 2 hrs to fix

    Function up has 54 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/0765-remote-transcoding.ts - About 2 hrs to fix

      Function updateVideoPlaylist has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function updateVideoPlaylist (req: express.Request, res: express.Response) {
        const videoPlaylistInstance = res.locals.videoPlaylistFull
        const videoPlaylistInfoToUpdate = req.body as VideoPlaylistUpdate
      
        const wasPrivatePlaylist = videoPlaylistInstance.privacy === VideoPlaylistPrivacy.PRIVATE
      Severity: Major
      Found in server/core/controllers/api/video-playlist.ts - About 2 hrs to fix

        Function buildRegisterHelpers has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          buildRegisterHelpers (): RegisterServerOptions {
            const registerHook = this.buildRegisterHook()
            const registerSetting = this.buildRegisterSetting()
        
            const getRouter = this.buildGetRouter()
        Severity: Major
        Found in server/core/lib/plugins/register-helpers.ts - About 2 hrs to fix

          Function getPlayerLoadOptions has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async getPlayerLoadOptions (options: {
              video: VideoDetails
              captionsResponse: Response
          
              storyboardsResponse: Response
          Severity: Major
          Found in client/src/standalone/videos/shared/player-options-builder.ts - About 2 hrs to fix

            Function assignCommands has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private assignCommands () {
                this.bulk = new BulkCommand(this)
                this.cli = new CLICommand(this)
                this.customPage = new CustomPagesCommand(this)
                this.feed = new FeedCommand(this)
            Severity: Major
            Found in packages/server-commands/src/server/server.ts - About 2 hrs to fix

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

              import { pick } from '@peertube/peertube-core-utils'
              import { ffprobePromise, getVideoStreamDuration } from '@peertube/peertube-ffmpeg'
              import {
                LiveVideoLatencyMode,
                ThumbnailType,
              Severity: Minor
              Found in server/core/lib/user-import-export/importers/videos-importer.ts - About 2 hrs to fix

                File plugin.service.ts has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { firstValueFrom, Observable, of } from 'rxjs'
                import { catchError, map, shareReplay } from 'rxjs/operators'
                import { HttpClient } from '@angular/common/http'
                import { Inject, Injectable, LOCALE_ID, NgZone } from '@angular/core'
                import { VideoEditType } from '@app/+videos/+video-edit/shared/video-edit.type'
                Severity: Minor
                Found in client/src/app/core/plugins/plugin.service.ts - About 2 hrs to fix

                  Function ScopeNames.SUMMARY has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => {
                      const serverInclude: IncludeOptions = {
                        attributes: [ 'host' ],
                        model: ServerModel.unscoped(),
                        required: !!options.whereServer,
                  Severity: Major
                  Found in server/core/models/account/account.ts - About 2 hrs to fix

                    Function constructor has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      constructor (
                        protected route: ActivatedRoute,
                        protected router: Router,
                        private notifier: Notifier,
                        private serverService: ServerService,

                      Function hijackMouseTooltip has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        private hijackMouseTooltip (evt: Event) {
                          const sprite = this.sprites[this.url]
                          const imgWidth = sprite.naturalWidth
                          const imgHeight = sprite.naturalHeight
                          const seekBarEl = this.seekBar.el()
                      Severity: Major
                      Found in client/src/assets/player/shared/control-bar/storyboard-plugin.ts - About 2 hrs to fix

                        Function loadVideo has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private loadVideo (options: {
                            videoId: string
                            forceAutoplay: boolean
                            liveRefresh?: boolean
                            videoPassword?: string
                        Severity: Major
                        Found in client/src/app/+videos/+video-watch/video-watch.component.ts - About 2 hrs to fix

                          Function loadPlayer has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            private async loadPlayer (options: {
                              loggedInOrAnonymousUser: User
                              forceAutoplay: boolean
                            }) {
                              const { loggedInOrAnonymousUser, forceAutoplay } = options
                          Severity: Major
                          Found in client/src/app/+videos/+video-watch/video-watch.component.ts - About 2 hrs to fix

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

                            import { NgFor, NgIf } from '@angular/common'
                            import { Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'
                            import { ActivatedRoute } from '@angular/router'
                            import { AuthService, ComponentPagination, ConfirmService, Notifier, User, hasMoreItems } from '@app/core'
                            import { HooksService } from '@app/core/plugins/hooks.service'

                              Function processStudioTranscoding has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export async function processStudioTranscoding (options: ProcessOptions<RunnerJobStudioTranscodingPayload>) {
                                const { server, job, runnerToken } = options
                                const payload = job.payload
                              
                                let videoInputPath: string
                              Severity: Major
                              Found in apps/peertube-runner/src/server/process/shared/process-studio.ts - About 2 hrs to fix

                                Function processVideo has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                Open

                                async function processVideo (videoId: number) {
                                  const video = await VideoModel.loadWithFiles(videoId)
                                  if (video.isLive) return
                                
                                  const files = await Promise.all(video.getAllFiles().map(f => VideoFileModel.loadWithMetadata(f.id)))
                                Severity: Minor
                                Found in server/scripts/migrations/peertube-6.3.ts - About 2 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 processActivityPubFollow has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                Open

                                async function processActivityPubFollow (job: Job) {
                                  const payload = job.data as ActivitypubFollowPayload
                                  const host = payload.host
                                
                                  const handle = host
                                Severity: Minor
                                Found in server/core/lib/job-queue/handlers/activitypub-follow.ts - About 2 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 buildHandlers has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  private buildHandlers () {
                                    const handlers: KeyHandler[] = [
                                      // Play
                                      {
                                        accept: e => (e.key === ' ' || e.key === 'MediaPlayPause'),
                                Severity: Minor
                                Found in client/src/assets/player/shared/hotkeys/peertube-hotkeys-plugin.ts - About 2 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 onStatusChanged has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  private onStatusChanged (options: {
                                    form: FormGroup
                                    formErrors: FormReactiveErrors
                                    validationMessages: FormReactiveValidationMessages
                                    onlyDirty?: boolean // default true
                                Severity: Minor
                                Found in client/src/app/shared/shared-forms/form-reactive.service.ts - About 2 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 checkAvailableJobs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  private async checkAvailableJobs () {
                                    if (!this.initialized) return
                                    if (this.checkingAvailableJobs) return
                                
                                    this.checkingAvailableJobs = true
                                Severity: Minor
                                Found in apps/peertube-runner/src/server/server.ts - About 2 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