Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

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

        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

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

        async function accountFollowersController (req: express.Request, res: express.Response) {
          const account = res.locals.account
          const activityPubResult = await actorFollowers(req, account.Actor)
        
          return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res)
        Severity: Major
        Found in server/core/controllers/activitypub/client.ts and 3 other locations - About 2 hrs to fix
        server/core/controllers/activitypub/client.ts on lines 282..287
        server/core/controllers/activitypub/client.ts on lines 406..411
        server/core/controllers/activitypub/client.ts on lines 413..418

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 80.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

        async function videoChannelFollowersController (req: express.Request, res: express.Response) {
          const videoChannel = res.locals.videoChannel
          const activityPubResult = await actorFollowers(req, videoChannel.Actor)
        
          return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res)
        Severity: Major
        Found in server/core/controllers/activitypub/client.ts and 3 other locations - About 2 hrs to fix
        server/core/controllers/activitypub/client.ts on lines 275..280
        server/core/controllers/activitypub/client.ts on lines 282..287
        server/core/controllers/activitypub/client.ts on lines 413..418

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 80.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

        async function videoChannelFollowingController (req: express.Request, res: express.Response) {
          const videoChannel = res.locals.videoChannel
          const activityPubResult = await actorFollowing(req, videoChannel.Actor)
        
          return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res)
        Severity: Major
        Found in server/core/controllers/activitypub/client.ts and 3 other locations - About 2 hrs to fix
        server/core/controllers/activitypub/client.ts on lines 275..280
        server/core/controllers/activitypub/client.ts on lines 282..287
        server/core/controllers/activitypub/client.ts on lines 406..411

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 80.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

        async function accountFollowingController (req: express.Request, res: express.Response) {
          const account = res.locals.account
          const activityPubResult = await actorFollowing(req, account.Actor)
        
          return activityPubResponse(activityPubContextify(activityPubResult, 'Collection', getContextFilter()), res)
        Severity: Major
        Found in server/core/controllers/activitypub/client.ts and 3 other locations - About 2 hrs to fix
        server/core/controllers/activitypub/client.ts on lines 275..280
        server/core/controllers/activitypub/client.ts on lines 406..411
        server/core/controllers/activitypub/client.ts on lines 413..418

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 80.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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
                              Severity
                              Category
                              Status
                              Source
                              Language