Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function sendMail has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async sendMail (options: EmailPayload) {
    if (!isEmailEnabled()) {
      logger.info('Cannot send mail because SMTP is not configured.')
      return
    }
Severity: Major
Found in server/core/lib/emailer.ts - About 2 hrs to fix

    File object-to-model-attributes.ts has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { arrayify, maxBy, minBy } from '@peertube/peertube-core-utils'
    import {
      ActivityHashTagObject,
      ActivityMagnetUrlObject,
      ActivityPlaylistSegmentHashesObject,

      Function buildMenu has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private buildMenu () {
          const clientRoutes = this.pluginService.getAllRegisteredClientRoutesForParent('/my-account') || {}
      
          this.menuEntries = [
            {
      Severity: Major
      Found in client/src/app/+my-account/my-account.component.ts - About 2 hrs to fix

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

          constructor (private config: PrimeNGConfig) {
            this.config.setTranslation({
              dayNames: [
                $localize`Sunday`,
                $localize`Monday`,

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

            constructor (hash: VideoServerModel, translations: { [ id: string ]: string } = {}) {
              const absoluteAPIUrl = getAbsoluteAPIUrl()
          
              this.createdAt = new Date(hash.createdAt.toString())
              this.publishedAt = new Date(hash.publishedAt.toString())
          Severity: Major
          Found in client/src/app/shared/shared-main/video/video.model.ts - About 2 hrs to fix

            VideosListComponent has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            @Component({
              selector: 'my-videos-list',
              templateUrl: './videos-list.component.html',
              styleUrls: [ './videos-list.component.scss' ],
              standalone: true,
            Severity: Minor
            Found in client/src/app/shared/shared-video-miniature/videos-list.component.ts - About 2 hrs to fix

              VideoUploadComponent has 22 functions (exceeds 20 allowed). Consider refactoring.
              Open

              @Component({
                selector: 'my-video-upload',
                templateUrl: './video-upload.component.html',
                styleUrls: [
                  '../shared/video-edit.component.scss',

                VideoCaptionEditModalContentComponent has 22 functions (exceeds 20 allowed). Consider refactoring.
                Open

                @Component({
                  styleUrls: [ './video-caption-edit-modal-content.component.scss' ],
                  templateUrl: './video-caption-edit-modal-content.component.html',
                  standalone: true,
                  imports: [

                  PluginService has 22 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  @Injectable()
                  export class PluginService implements ClientHook {
                    private static BASE_PLUGIN_API_URL = environment.apiUrl + '/api/v1/plugins'
                    private static BASE_PLUGIN_URL = environment.apiUrl + '/plugins'
                  
                  
                  Severity: Minor
                  Found in client/src/app/core/plugins/plugin.service.ts - About 2 hrs to fix

                    Function listLocalOfServer has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      static async listLocalOfServer (serverId: number) {
                        const actor = await getServerActor()
                        const buildVideoInclude = () => ({
                          model: VideoModel,
                          required: true,
                    Severity: Major
                    Found in server/core/models/redundancy/video-redundancy.ts - About 2 hrs to fix

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

                        constructor (player: videojs.Player, options?: P2PMediaLoaderPluginOptions) {
                          super(player)
                      
                          this.options = options
                      
                      

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

                          ngOnInit () {
                            this.initialize()
                        
                            this.inputFilters = this.videoAdminService.buildAdminInputFilter()
                        
                        
                        Severity: Major
                        Found in client/src/app/+admin/overview/videos/video-list.component.ts - About 2 hrs to fix

                          Function getLiveTranscodingCommand has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async getLiveTranscodingCommand (options: LiveTranscodingOptions) {
                              this.commandWrapper.debugLog('Building live transcoding command', options)
                          
                              const {
                                inputUrl,
                          Severity: Major
                          Found in packages/ffmpeg/src/ffmpeg-live.ts - About 2 hrs to fix

                            Function presetVOD has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export async function presetVOD (options: {
                              commandWrapper: FFmpegCommandWrapper
                            
                              videoInputPath: string
                              separatedAudioInputPath?: string
                            Severity: Major
                            Found in packages/ffmpeg/src/shared/presets.ts - About 2 hrs to fix

                              File index.ts has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import express from 'express'
                              import { tokensRouter } from '@server/controllers/api/users/token.js'
                              import { Hooks } from '@server/lib/plugins/hooks.js'
                              import { OAuthTokenModel } from '@server/models/oauth/oauth-token.js'
                              import { MUserAccountDefault } from '@server/types/models/index.js'
                              Severity: Minor
                              Found in server/core/controllers/api/users/index.ts - About 2 hrs to fix

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

                                /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
                                
                                import { readdir } from 'fs/promises'
                                import { join } from 'path'
                                import { omit, wait } from '@peertube/peertube-core-utils'
                                Severity: Minor
                                Found in packages/server-commands/src/videos/live-command.ts - About 2 hrs to fix

                                  File notifier.ts has 262 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  import { UserNotificationSettingValue, UserNotificationSettingValueType } from '@peertube/peertube-models'
                                  import { MRegistration, MUser, MUserDefault } from '@server/types/models/user/index.js'
                                  import { MVideoBlacklistLightVideo, MVideoBlacklistVideo } from '@server/types/models/video/video-blacklist.js'
                                  import { logger, loggerTagsFactory } from '../../helpers/logger.js'
                                  import { CONFIG } from '../../initializers/config.js'
                                  Severity: Minor
                                  Found in server/core/lib/notifier/notifier.ts - About 2 hrs to fix

                                    Function replaceVideoSourceResumable has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    async function replaceVideoSourceResumable (req: express.Request, res: express.Response) {
                                      const videoPhysicalFile = res.locals.updateVideoFileResumable
                                      const user = res.locals.oauth.token.User
                                    
                                      const videoFile = await buildNewFile({ path: videoPhysicalFile.path, mode: 'web-video', ffprobe: res.locals.ffprobe })
                                    Severity: Major
                                    Found in server/core/controllers/api/videos/source.ts - About 2 hrs to fix

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

                                      import express from 'express'
                                      import { body } from 'express-validator'
                                      import { isLiveLatencyModeValid } from '@server/helpers/custom-validators/video-lives.js'
                                      import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js'
                                      import { isLocalLiveVideoAccepted } from '@server/lib/moderation.js'
                                      Severity: Minor
                                      Found in server/core/middlewares/validators/videos/video-live.ts - About 2 hrs to fix

                                        Function getUser has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        async function getUser (usernameOrEmail?: string, password?: string, bypassLogin?: BypassLogin) {
                                          // Special treatment coming from a plugin
                                          if (bypassLogin && bypassLogin.bypass === true) {
                                            logger.info('Bypassing oauth login by plugin %s.', bypassLogin.pluginName)
                                        
                                        
                                        Severity: Minor
                                        Found in server/core/lib/auth/oauth-model.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