Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function addVideoJobsAfterUpdate has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function addVideoJobsAfterUpdate (options: {
  video: MVideoFullLight
  isNewVideoForFederation: boolean

  nameChanged: boolean
Severity: Minor
Found in server/core/lib/video-jobs.ts - About 1 hr to fix

    Function buildSystemItems has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private buildSystemItems () {
        const systemItems: TopMenuDropdownParam = {
          label: $localize`System`,
          children: []
        }
    Severity: Minor
    Found in client/src/app/+admin/admin.component.ts - About 1 hr to fix

      Function resolveRemoteParentComment has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function resolveRemoteParentComment (params: ResolveThreadParams) {
        const { url, comments } = params
      
        if (comments.length > ACTIVITY_PUB.MAX_RECURSION_COMMENTS) {
          throw new Error('Recursion limit reached when resolving a thread')
      Severity: Minor
      Found in server/core/lib/activitypub/video-comments.ts - About 1 hr to fix

        Function getP2PMediaLoaderOptions has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private getP2PMediaLoaderOptions (options: {
            redundancyUrlManager: RedundancyUrlManager | null
            segmentValidator: SegmentValidator | null
          }): HlsJsEngineSettings {
            const { redundancyUrlManager, segmentValidator } = options

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

            constructor (player: videojs.Player, options?: SettingsMenuItemOptions) {
              super(player, options)
          
              this.settingsButton = options.menuButton
              this.dialog = this.settingsButton.dialog
          Severity: Minor
          Found in client/src/assets/player/shared/settings/settings-menu-item.ts - About 1 hr to fix

            Function tryToResolveThreadFromVideo has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function tryToResolveThreadFromVideo (params: ResolveThreadParams) {
              const { url, comments, commentCreated } = params
            
              // Maybe it's a reply to a video?
              // If yes, it's done: we resolved all the thread
            Severity: Minor
            Found in server/core/lib/activitypub/video-comments.ts - About 1 hr to fix

              Function fetchPage has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private fetchPage (currentVideo: VideoDetails, totalItems: number): Observable<Video[]> {
                  const pagination = { currentPage: 1, itemsPerPage: totalItems }
              
                  return this.userService.getAnonymousOrLoggedUser()
                    .pipe(

                Function goLive has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  goLive () {
                    if (this.isOrHasGoingLive) return
                    this.isOrHasGoingLive = true
                
                    const name = 'Live'

                  Function buildCommonLinks has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    buildCommonLinks (config: HTMLServerConfig): MenuSection {
                      let links: MenuLink[] = []
                  
                      if (config.homepage.enabled) {
                        links.push({
                  Severity: Minor
                  Found in client/src/app/core/menu/menu.service.ts - About 1 hr to fix

                    Function checkLiveConfig has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function checkLiveConfig () {
                      if (CONFIG.LIVE.ENABLED === true) {
                        if (CONFIG.LIVE.ALLOW_REPLAY === true && CONFIG.TRANSCODING.ENABLED === false) {
                          throw new Error('Live allow replay cannot be enabled if transcoding is not enabled.')
                        }
                    Severity: Minor
                    Found in server/core/initializers/checker-after-init.ts - About 1 hr 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 videoLiveAddValidator has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                        if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
                    
                        if (!isValidPasswordProtectedPrivacy(req, res)) return cleanUpReqFiles(req)
                    
                    
                    Severity: Minor
                    Found in server/core/middlewares/validators/videos/video-live.ts - About 1 hr 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 install has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async install (options: {
                        toInstall: string
                        version?: string
                        fromDisk?: boolean // default false
                        register?: boolean // default true
                    Severity: Minor
                    Found in server/core/lib/plugins/plugin-manager.ts - About 1 hr 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 buildVideosHelpers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function buildVideosHelpers () {
                      return {
                        loadByUrl: (url: string) => {
                          return VideoModel.loadByUrl(url)
                        },
                    Severity: Minor
                    Found in server/core/lib/plugins/plugin-helpers-builder.ts - About 1 hr 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 sanitize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      protected sanitize (o: UserSettingsExportJSON) {
                        if (!isUserNSFWPolicyValid(o.nsfwPolicy)) o.nsfwPolicy = undefined
                        if (!isUserAutoPlayVideoValid(o.autoPlayVideo)) o.autoPlayVideo = undefined
                        if (!isUserAutoPlayNextVideoValid(o.autoPlayNextVideo)) o.autoPlayNextVideo = undefined
                        if (!isUserAutoPlayNextVideoPlaylistValid(o.autoPlayNextVideoPlaylist)) o.autoPlayNextVideoPlaylist = undefined

                    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 cleanupImportedStaticFilePaths has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      protected async cleanupImportedStaticFilePaths (archiveFiles: Record<string, string | Record<string, string>>) {
                        if (!archiveFiles || typeof archiveFiles !== 'object') return
                    
                        for (const file of Object.values(archiveFiles)) {
                          if (!file) continue

                    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 buildMuxInput has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function buildMuxInput (
                      video: MVideo,
                      videoFile: MVideoFile
                    ): Promise<{ input: Readable, isTmpDestination: false } | { input: string, isTmpDestination: boolean }> {
                    
                    
                    Severity: Minor
                    Found in server/core/lib/video-file.ts - About 1 hr 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 processVideosViewsStats has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function processVideosViewsStats () {
                      const lastHour = new Date()
                    
                      // In test mode, we run this function multiple times per hour, so we don't want the values of the previous hour
                      if (!isTestOrDevInstance()) lastHour.setHours(lastHour.getHours() - 1)
                    Severity: Minor
                    Found in server/core/lib/job-queue/handlers/video-views-stats.ts - About 1 hr 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 importObject has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      protected async importObject (channelImportData: SanitizedObject) {
                        const account = this.user.Account
                        const existingChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(channelImportData.name)
                    
                        if (existingChannel) {
                    Severity: Minor
                    Found in server/core/lib/user-import-export/importers/channels-importer.ts - About 1 hr 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 createTranscodingJobs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async createTranscodingJobs (options: {
                        transcodingType: 'hls' | 'webtorrent' | 'web-video' // TODO: remove webtorrent in v7
                        video: MVideoFullLight
                        resolutions: number[]
                        isNewVideo: boolean

                    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 disposeDynamicPluginsIfNeeded has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private disposeDynamicPluginsIfNeeded () {
                        if (!this.player) return
                    
                        if (this.player.usingPlugin('peertubeMobile')) this.player.peertubeMobile().dispose()
                        if (this.player.usingPlugin('peerTubeHotkeysPlugin')) this.player.peerTubeHotkeysPlugin().dispose()
                    Severity: Minor
                    Found in client/src/assets/player/peertube-player.ts - About 1 hr 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