Chocobozzz/PeerTube

View on GitHub

Showing 1,189 of 3,041 total issues

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

import { 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 { forkJoin, map, Observable, of, Subscription, switchMap } from 'rxjs'
    import { PlatformLocation, NgClass, NgIf, NgTemplateOutlet } from '@angular/common'
    import { Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
    import { ActivatedRoute, Router, RouterLink } from '@angular/router'
    import {
    Severity: Major
    Found in client/src/app/+videos/+video-watch/video-watch.component.ts - About 1 day to fix

      File config.ts has 699 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 691 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import sample from 'lodash-es/sample.js'
        import { literal, Op, QueryTypes, Transaction, WhereOptions } from 'sequelize'
        import {
          AllowNull,
          BeforeDestroy,
        Severity: Major
        Found in server/core/models/redundancy/video-redundancy.ts - About 1 day to fix

          Function getHTMLServerConfig has 250 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-comment.ts has 573 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { Op, Order, QueryTypes, Sequelize, Transaction } from 'sequelize'
              import {
                AllowNull,
                BelongsTo,
                Column,
              Severity: Major
              Found in server/core/models/video/video-comment.ts - About 1 day to fix

                File videos-id-list-query-builder.ts has 571 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

                  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 53 (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 videos-command.ts has 510 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

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

                          import { forkJoin } from 'rxjs'
                          import { map } from 'rxjs/operators'
                          import { SelectChannelItem, SelectOptionsItem } from 'src/types/select-options-item.model'
                          import { ChangeDetectorRef, Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
                          import { AbstractControl, FormArray, FormGroup, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms'
                          Severity: Major
                          Found in client/src/app/+videos/+video-edit/shared/video-edit.component.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 481 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import { SortMeta } from 'primeng/api'
                              import { from, Observable, of, throwError } from 'rxjs'
                              import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
                              import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
                              import { Injectable } from '@angular/core'
                              Severity: Minor
                              Found in client/src/app/shared/shared-main/video/video.service.ts - About 7 hrs to fix

                                File live-manager.ts has 463 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 job-queue.ts has 451 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  import {
                                    FlowJob,
                                    FlowProducer,
                                    Job,
                                    JobsOptions,
                                  Severity: Minor
                                  Found in server/core/lib/job-queue/job-queue.ts - About 6 hrs to fix

                                    File videos.ts has 446 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