Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

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

  buildGroupedDateLabels () {
    let currentGroupedDate: GroupDate = GroupDate.UNKNOWN

    const periods = [
      {
Severity: Minor
Found in client/src/app/shared/shared-video-miniature/videos-list.component.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 videoModelToFormattedJSON has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoFormattingJSONOptions = {}): Video {
  const span = tracer.startSpan('peertube.VideoModel.toFormattedJSON')

  const userHistory = isArray(video.UserVideoHistories)
    ? video.UserVideoHistories[0]
Severity: Major
Found in server/core/models/video/formatter/video-api-format.ts - About 2 hrs to fix

    Function synchronizeChannel has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function synchronizeChannel (options: {
      channel: MChannelAccountDefault
      externalChannelUrl: string
      videosCountLimit: number
      channelSync?: MChannelSync
    Severity: Major
    Found in server/core/lib/sync-channel.ts - About 2 hrs to fix

      Function getVideojsOptions has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        getVideojsOptions (): videojs.PlayerOptions {
          const html5 = {
            preloadTextTracks: false,
            // Prevent a bug on iOS where the text tracks added by peertube plugin are removed on play
            // See https://github.com/Chocobozzz/PeerTube/issues/6351
      Severity: Major
      Found in client/src/assets/player/peertube-player.ts - About 2 hrs to fix

        Function buildTranscodingStream has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private async buildTranscodingStream (
            options: Pick<LiveTranscodingOptions, 'inputUrl' | 'bitrate' | 'ratio' | 'probe' | 'hasAudio' | 'splitAudioAndVideo'> & {
              command: FfmpegCommand
              resolution: number
              fps: number
        Severity: Major
        Found in packages/ffmpeg/src/ffmpeg-live.ts - About 2 hrs to fix

          Function buildChartOptions has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private buildChartOptions (graphId: ActiveGraphId): ChartConfiguration<'line' | 'bar'> {
              const dataBuilders: {
                [ id in ActiveGraphId ]: (rawData: ChartIngestData) => ChartBuilderResult
              } = {
                retention: (rawData: VideoStatsRetention) => this.buildRetentionChartOptions(rawData),
          Severity: Major
          Found in client/src/app/+stats/video/video-stats.component.ts - About 2 hrs to fix

            File video-table-attributes.ts has 259 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /**
             *
             * Class to build video attributes/join names we want to fetch from the database
             *
             */
            Severity: Minor
            Found in server/core/models/video/sql/video/shared/video-table-attributes.ts - About 2 hrs to fix

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

              import { buildAspectRatio } from '@peertube/peertube-core-utils'
              import {
                ffprobePromise,
                getChaptersFromContainer, getVideoStreamDuration
              } from '@peertube/peertube-ffmpeg'
              Severity: Minor
              Found in server/core/lib/job-queue/handlers/video-import.ts - About 2 hrs to fix

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

                import { omit, pick } from '@peertube/peertube-core-utils'
                import {
                  BooleanBothQuery,
                  HttpStatusCode,
                  ResultList,
                Severity: Minor
                Found in packages/server-commands/src/videos/playlists-command.ts - About 2 hrs to fix

                  Function up has 55 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/0520-abuses-split.ts - About 2 hrs to fix

                    Function import has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async import (importModel: MUserImport) {
                        const resultSummary: UserImportResultSummary = {
                          stats: {
                            blocklist: this.buildSummary(),
                            channels: this.buildSummary(),
                    Severity: Major
                    Found in server/core/lib/user-import-export/user-importer.ts - About 2 hrs to fix

                      Function update has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async update () {
                          await this.waitPendingCheck()
                          this.forceCheck()
                      
                          if (!this.form.valid || this.isUpdatingVideo === true) return
                      Severity: Major
                      Found in client/src/app/+videos/+video-edit/video-update.component.ts - About 2 hrs to fix

                        Function buildActiveFilters has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          buildActiveFilters () {
                            this.activeFilters = []
                        
                            this.activeFilters.push({
                              key: 'nsfw',
                        Severity: Major
                        Found in client/src/app/shared/shared-video-miniature/video-filters.model.ts - About 2 hrs to fix

                          Function buildVideoActions has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            private buildVideoActions (): DropdownAction<ProcessedAbuse>[] {
                              if (!this.isAdminView()) return []
                          
                              return [
                                {
                          Severity: Major
                          Found in client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts - About 2 hrs to fix

                            Function sendResumableChunks has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              protected async sendResumableChunks <T> (options: OverrideCommandOptions & {
                                pathUploadId: string
                                path: string
                                videoFilePath: string
                                size: number
                            Severity: Major
                            Found in packages/server-commands/src/shared/abstract-command.ts - About 2 hrs to fix

                              File user-notitication-list-query-builder.ts has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import { Sequelize } from 'sequelize'
                              import { AbstractRunQuery, ModelBuilder } from '@server/models/shared/index.js'
                              import { UserNotificationModelForApi } from '@server/types/models/index.js'
                              import { ActorImageType } from '@peertube/peertube-models'
                              import { getSort } from '../../shared/index.js'
                              Severity: Minor
                              Found in server/core/models/user/sql/user-notitication-list-query-builder.ts - About 2 hrs to fix

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

                                @Scopes(() => ({
                                  [ScopeNames.WITH_VIDEO_UUID_AND_REMOTE]: {
                                    include: [
                                      {
                                        attributes: [ 'id', 'uuid', 'remote' ],
                                Severity: Minor
                                Found in server/core/models/video/video-caption.ts - About 2 hrs to fix

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

                                  export class RegisterHelpers {
                                    private readonly transcodingProfiles: {
                                      [ npmName: string ]: {
                                        type: 'vod' | 'live'
                                        encoder: string
                                  Severity: Minor
                                  Found in server/core/lib/plugins/register-helpers.ts - About 2 hrs to fix

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

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

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

                                      @Component({
                                        selector: 'my-video-comment',
                                        templateUrl: './video-comment.component.html',
                                        styleUrls: [ './video-comment.component.scss' ],
                                        standalone: true,
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language