Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function runMetricsInterval has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  private runMetricsInterval () {
    if (this.metricsInterval) clearInterval(this.metricsInterval)
    if (!this.options_.metricsUrl()) return

    this.metricsInterval = setInterval(() => {
Severity: Minor
Found in client/src/assets/player/shared/metrics/metrics-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 processDeleteActivity has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

async function processDeleteActivity (options: APProcessorOptions<ActivityDelete>) {
  const { activity, byActor } = options

  const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id

Severity: Minor
Found in server/core/lib/activitypub/process/process-delete.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 initDatabaseModels has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function initDatabaseModels (silent: boolean) {
  sequelizeTypescript.addModels([
    ApplicationModel,
    ActorModel,
    ActorFollowModel,
Severity: Major
Found in server/core/initializers/database.ts - About 2 hrs to fix

    File abstract-video-query-builder.ts has 280 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { Sequelize } from 'sequelize'
    import validator from 'validator'
    import { MUserAccountId } from '@server/types/models/index.js'
    import { ActorImageType } from '@peertube/peertube-models'
    import { AbstractRunQuery } from '../../../../shared/abstract-run-query.js'

      Function sanitize has 68 lines of code (exceeds 25 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: Major
      Found in server/core/lib/user-import-export/importers/videos-importer.ts - About 2 hrs to fix

        Function run has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function run () {
          const typesPath = currentDir(import.meta.url)
          const typesDistTMPPath = join(typesPath, 'dist-tmp')
        
          await remove(typesDistTMPPath)
        Severity: Major
        Found in packages/types-generator/generate-package.ts - About 2 hrs to fix

          EditBasicConfigurationComponent has 24 functions (exceeds 20 allowed). Consider refactoring.
          Open

          @Component({
            selector: 'my-edit-basic-configuration',
            templateUrl: './edit-basic-configuration.component.html',
            styleUrls: [ './edit-custom-config.component.scss' ],
            standalone: true,

            MenuComponent has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

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

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

              import { wait } from '@peertube/peertube-core-utils'
              import {
                ffprobePromise,
                getVideoStreamBitrate,
                getVideoStreamDimensionsInfo,
              Severity: Minor
              Found in apps/peertube-runner/src/server/process/shared/process-live.ts - About 2 hrs to fix

                Function runMuxingSession has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private async runMuxingSession (options: {
                    sessionId: string
                    videoLive: MVideoLiveVideoWithSetting
                
                    user: MUser
                Severity: Major
                Found in server/core/lib/live/live-manager.ts - About 2 hrs to fix

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

                  import { arrayify } from '@peertube/peertube-core-utils'
                  import { HttpStatusCode, UserRight, VideoCommentPolicy } from '@peertube/peertube-models'
                  import { isStringArray } from '@server/helpers/custom-validators/search.js'
                  import { canVideoBeFederated } from '@server/lib/activitypub/videos/federate.js'
                  import { MUserAccountUrl } from '@server/types/models/index.js'
                  Severity: Minor
                  Found in server/core/middlewares/validators/videos/video-comments.ts - About 2 hrs to fix

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

                    import { switchMap } from 'rxjs/operators'
                    import {
                      ChangeDetectionStrategy,
                      ChangeDetectorRef,
                      Component,

                      Function plainTextPlugin has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function plainTextPlugin (markdownIt: any) {
                        function plainTextRule (state: any) {
                          const text = scan(state.tokens)
                      
                          markdownIt.plainText = text
                      Severity: Minor
                      Found in server/core/helpers/markdown.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 videoPlaylistsGetValidator has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const videoPlaylistsGetValidator = (fetchType: VideoPlaylistFetchType) => {
                        return [
                          isValidPlaylistIdParam('playlistId'),
                      
                          async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                      Severity: Minor
                      Found in server/core/middlewares/validators/videos/video-playlists.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 presetVOD has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export async function presetVOD (options: {
                        commandWrapper: FFmpegCommandWrapper
                      
                        videoInputPath: string
                        separatedAudioInputPath?: string
                      Severity: Minor
                      Found in packages/ffmpeg/src/shared/presets.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 secondsToTime has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function secondsToTime (options: {
                        seconds: number
                        format: 'short' | 'full' | 'locale-string' // default 'short'
                        symbol?: string
                      } | number) {
                      Severity: Minor
                      Found in packages/core-utils/src/common/date.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 up has 64 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/0830-keep-original-file.ts - About 2 hrs to fix

                        Function buildVideosHelpers has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function buildVideosHelpers () {
                          return {
                            loadByUrl: (url: string) => {
                              return VideoModel.loadByUrl(url)
                            },
                        Severity: Major
                        Found in server/core/lib/plugins/plugin-helpers-builder.ts - About 2 hrs to fix

                          File audit-logger.ts has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import {
                            AdminAbuse,
                            CustomConfig,
                            User,
                            VideoChannel,
                          Severity: Minor
                          Found in server/core/helpers/audit-logger.ts - About 2 hrs to fix

                            Function defineRedundancyProgram has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export function defineRedundancyProgram () {
                              const program = new Command()
                                .name('redundancy')
                                .description('Manage instance redundancies')
                                .alias('r')
                            Severity: Major
                            Found in apps/peertube-cli/src/peertube-redundancy.ts - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language