Chocobozzz/PeerTube

View on GitHub

Showing 1,230 of 3,155 total issues

File constants.ts has 1285 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { maxBy, minBy, randomInt } from '@peertube/peertube-core-utils'
import {
  AbuseState,
  AbuseStateType,
  ActivityPubActorType,
Severity: Major
Found in server/core/initializers/constants.ts - About 3 days to fix

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

    import { NgClass, NgIf, NgTemplateOutlet, PlatformLocation } from '@angular/common'
    import { Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
    import { ActivatedRoute, Router, RouterLink } from '@angular/router'
    import {
      AuthService,
    Severity: Major
    Found in client/src/app/+videos/+video-watch/video-watch.component.ts - About 1 day to fix

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

      import bytes from 'bytes'
      import { IConfig } from 'config'
      import { createRequire } from 'module'
      import { dirname, join } from 'path'
      import {
      Severity: Major
      Found in server/core/initializers/config.ts - About 1 day to fix

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

        import {
          ActivityVideoUrlObject,
          CacheFileObject,
          FileRedundancyInformation,
          StreamingPlaylistRedundancyInformation,
        Severity: Major
        Found in server/core/models/redundancy/video-redundancy.ts - About 1 day to fix

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

          import { pick } from '@peertube/peertube-core-utils'
          import {
            ActivityTagObject,
            ActivityTombstoneObject,
            UserRight,
          Severity: Major
          Found in server/core/models/video/video-comment.ts - About 1 day to fix

            File videos-id-list-query-builder.ts has 586 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { Sequelize, Transaction } from 'sequelize'
            import validator from 'validator'
            import { forceNumber } from '@peertube/peertube-core-utils'
            import { VideoInclude, VideoIncludeType, VideoPrivacy, VideoPrivacyType, VideoState } from '@peertube/peertube-models'
            import { exists } from '@server/helpers/custom-validators/misc.js'
            Severity: Major
            Found in server/core/models/video/sql/video/videos-id-list-query-builder.ts - About 1 day to fix

              Function getHTMLServerConfig has 251 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async getHTMLServerConfig (): Promise<HTMLServerConfig> {
                  if (this.serverCommit === undefined) this.serverCommit = await getServerCommit()
              
                  const serverActor = await getServerActor()
              
              
              Severity: Major
              Found in server/core/lib/server-config-manager.ts - About 1 day to fix

                Function ngOnInit has 244 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  ngOnInit () {
                    this.serverConfig = this.serverService.getHTMLConfig()
                
                    const formGroupData: { [key in keyof ComponentCustomConfig ]: any } = {
                      instance: {

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

                  import { ChartConfiguration, ChartData, ChartOptions, PluginOptionsByType, Scale, TooltipItem, defaults as ChartJSDefaults } from 'chart.js'
                  import zoomPlugin from 'chartjs-plugin-zoom'
                  import { Observable, of } from 'rxjs'
                  import { SelectOptionsItem } from 'src/types'
                  import { Component, Inject, LOCALE_ID, OnInit } from '@angular/core'
                  Severity: Major
                  Found in client/src/app/+stats/video/video-stats.component.ts - About 1 day to fix

                    Function customConfig has 234 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function customConfig (): CustomConfig {
                      return {
                        instance: {
                          name: CONFIG.INSTANCE.NAME,
                          shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
                    Severity: Major
                    Found in server/core/controllers/api/config.ts - About 1 day to fix

                      Redis has 59 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Redis {
                      
                        private static instance: Redis
                        private initialized = false
                        private connected = false
                      Severity: Major
                      Found in server/core/lib/redis.ts - About 1 day to fix

                        Function buildIdsListQuery has a Cognitive Complexity of 54 (exceeds 5 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: Minor
                        Found in server/core/models/video/sql/video/videos-id-list-query-builder.ts - About 1 day 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 video-edit.component.ts has 515 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { DatePipe, NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common'
                        import { ChangeDetectorRef, Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
                        import { AbstractControl, FormArray, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'
                        import { HooksService, PluginService, ServerService } from '@app/core'
                        import { removeElementFromArray } from '@app/helpers'
                        Severity: Major
                        Found in client/src/app/+videos/+video-edit/shared/video-edit.component.ts - About 1 day to fix

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

                          /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
                          
                          import validator from 'validator'
                          import { getAllPrivacies, omit, pick, wait } from '@peertube/peertube-core-utils'
                          import {
                          Severity: Major
                          Found in packages/server-commands/src/videos/videos-command.ts - About 1 day to fix

                            Function onFingerSwipe has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
                            Open

                              onFingerSwipe (direction: 'left' | 'right' | 'up' | 'down', action: () => void, removeEventOnEnd = true) {
                                let touchDownClientX: number
                                let touchDownClientY: number
                            
                                const onTouchStart = (event: TouchEvent) => {
                            Severity: Minor
                            Found in client/src/app/core/wrappers/screen.service.ts - About 7 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 plugin-manager.ts has 487 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import express from 'express'
                            import { createReadStream, createWriteStream } from 'fs'
                            import { ensureDir, outputFile, readJSON } from 'fs-extra/esm'
                            import { Server } from 'http'
                            import { createRequire } from 'module'
                            Severity: Minor
                            Found in server/core/lib/plugins/plugin-manager.ts - About 7 hrs to fix

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

                              import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
                              import { Injectable } from '@angular/core'
                              import { AuthService, ComponentPaginationLight, ConfirmService, RestExtractor, RestService, ServerService, UserService } from '@app/core'
                              import { objectToFormData } from '@app/helpers'
                              import { arrayify } from '@peertube/peertube-core-utils'
                              Severity: Minor
                              Found in client/src/app/shared/shared-main/video/video.service.ts - About 7 hrs to fix

                                Function sanitize has a Cognitive Complexity of 49 (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 7 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 live-manager.ts has 466 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import { pick, wait } from '@peertube/peertube-core-utils'
                                import {
                                  ffprobePromise,
                                  getVideoStreamBitrate,
                                  getVideoStreamDimensionsInfo,
                                Severity: Minor
                                Found in server/core/lib/live/live-manager.ts - About 7 hrs to fix

                                  File videos.ts has 454 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 6 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language