Chocobozzz/PeerTube

View on GitHub

Showing 1,230 of 3,155 total issues

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

import { About, ActorImageType, ActorImageType_Type, CustomConfig, HttpStatusCode, ServerConfig } from '@peertube/peertube-models'
import { DeepPartial } from '@peertube/peertube-typescript-utils'
import merge from 'lodash-es/merge.js'
import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command.js'

Severity: Minor
Found in packages/server-commands/src/server/config-command.ts - About 5 hrs to fix

    File server.ts has 389 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { randomInt } from '@peertube/peertube-core-utils'
    import { Video, VideoChannel, VideoChannelSync, VideoCreateResult, VideoDetails } from '@peertube/peertube-models'
    import { parallelTests, root } from '@peertube/peertube-node-utils'
    import { ChildProcess, fork } from 'child_process'
    import { copy } from 'fs-extra/esm'
    Severity: Minor
    Found in packages/server-commands/src/server/server.ts - About 5 hrs to fix

      VideoCommentModel has 40 functions (exceeds 20 allowed). Consider refactoring.
      Open

      @Scopes(() => ({
        [ScopeNames.WITH_ACCOUNT]: {
          include: [
            {
              model: AccountModel
      Severity: Minor
      Found in server/core/models/video/video-comment.ts - About 5 hrs to fix

        PluginManager has 40 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class PluginManager implements ServerHook {
        
          private static instance: PluginManager
        
          private registeredPlugins: { [name: string]: RegisteredPlugin } = {}
        Severity: Minor
        Found in server/core/lib/plugins/plugin-manager.ts - About 5 hrs to fix

          ConfigCommand has 39 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class ConfigCommand extends AbstractCommand {
          
            static getCustomConfigResolutions (enabled: boolean, with0p = false) {
              return {
                '0p': enabled && with0p,
          Severity: Minor
          Found in packages/server-commands/src/server/config-command.ts - About 5 hrs to fix

            File server-config-manager.ts has 374 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import {
              HTMLServerConfig,
              RegisteredExternalAuthConfig,
              RegisteredIdAndPassAuthConfig,
              ServerConfig,
            Severity: Minor
            Found in server/core/lib/server-config-manager.ts - About 5 hrs to fix

              Function buildActions has 123 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private buildActions () {
                  this.videoActions = [
                    [
                      {
                        label: $localize`Save to playlist`,

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

                import { forceNumber } from '@peertube/peertube-core-utils'
                import {
                  HttpStatusCode,
                  VideoPlaylistCreate,
                  VideoPlaylistCreateResult,
                Severity: Minor
                Found in server/core/controllers/api/video-playlist.ts - About 4 hrs to fix

                  File videos-list.component.ts has 366 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import * as debug from 'debug'
                  import { fromEvent, Observable, Subject, Subscription } from 'rxjs'
                  import { concatMap, debounceTime, map, switchMap } from 'rxjs/operators'
                  import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core'
                  import { ActivatedRoute, RouterLinkActive, RouterLink } from '@angular/router'
                  Severity: Minor
                  Found in client/src/app/shared/shared-video-miniature/videos-list.component.ts - About 4 hrs to fix

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

                    import express from 'express'
                    import {
                      ActorImageType,
                      HttpStatusCode,
                      VideoChannelCreate,
                    Severity: Minor
                    Found in server/core/controllers/api/video-channel.ts - About 4 hrs to fix

                      Function getZanataContributors has 119 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function getZanataContributors () {
                        return [
                          { username: 'abdhessuk', name: 'Abd Hessuk' },
                          { username: 'abidin24', name: 'abidin toumi' },
                          { username: 'aditoo', name: 'Lorem Ipsum' },
                      Severity: Major
                      Found in scripts/generate-code-contributors.ts - About 4 hrs to fix

                        Function buildPeerTubePlayerLoadOptions has 118 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private buildPeerTubePlayerLoadOptions (options: {
                            video: VideoDetails
                            liveVideo: LiveVideo
                            videoCaptions: VideoCaption[]
                            videoChapters: VideoChapter[]
                        Severity: Major
                        Found in client/src/app/+videos/+video-watch/video-watch.component.ts - About 4 hrs to fix

                          File player-options-builder.ts has 362 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { peertubeTranslate } from '@peertube/peertube-core-utils'
                          import {
                            HTMLServerConfig,
                            LiveVideo,
                            Storyboard,
                          Severity: Minor
                          Found in client/src/standalone/videos/shared/player-options-builder.ts - About 4 hrs to fix

                            Function getSelect has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              private getSelect () {
                                return `SELECT
                                  "UserNotificationModel"."id",
                                  "UserNotificationModel"."type",
                                  "UserNotificationModel"."read",
                            Severity: Major
                            Found in server/core/models/user/sql/user-notitication-list-query-builder.ts - About 4 hrs to fix

                              VideoService has 35 functions (exceeds 20 allowed). Consider refactoring.
                              Open

                              @Injectable()
                              export class VideoService {
                                static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos'
                                static BASE_FEEDS_URL = environment.apiUrl + '/feeds/videos.'
                                static PODCAST_FEEDS_URL = environment.apiUrl + '/feeds/podcast/videos.xml'
                              Severity: Minor
                              Found in client/src/app/shared/shared-main/video/video.service.ts - About 4 hrs to fix

                                File user-moderation-dropdown.component.ts has 352 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core'
                                import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core'
                                import { BulkRemoveCommentsOfBody, User, UserRight } from '@peertube/peertube-models'
                                import { BlocklistService } from './blocklist.service'
                                import { BulkService } from './bulk.service'

                                  Function reloadDataInternal has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    protected reloadDataInternal () {
                                      debugLogger('Loading data.')
                                  
                                      const options = {
                                        pagination: this.pagination,
                                  Severity: Minor
                                  Found in client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts - About 4 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 updateVideo has 110 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  async function updateVideo (req: express.Request, res: express.Response) {
                                    const videoFromReq = res.locals.videoAll
                                    const oldVideoAuditView = new VideoAuditView(videoFromReq.toFormattedDetailsJSON())
                                    const videoInfoToUpdate: VideoUpdate = req.body
                                  
                                  
                                  Severity: Major
                                  Found in server/core/controllers/api/videos/update.ts - About 4 hrs to fix

                                    AccountModel has 34 functions (exceeds 20 allowed). Consider refactoring.
                                    Open

                                    @DefaultScope(() => ({
                                      include: [
                                        {
                                          model: ActorModel, // Default scope includes avatar and server
                                          required: true
                                    Severity: Minor
                                    Found in server/core/models/account/account.ts - About 4 hrs to fix

                                      Function getOverallStats has 107 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        static async getOverallStats (options: {
                                          video: MVideo
                                          startDate?: string
                                          endDate?: string
                                        }): Promise<VideoStatsOverall> {
                                      Severity: Major
                                      Found in server/core/models/view/local-video-viewer.ts - About 4 hrs to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language