Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function generateNodeinfo has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function generateNodeinfo (req: express.Request, res: express.Response) {
  const { totalVideos } = await VideoModel.getStats()
  const { totalLocalVideoComments } = await VideoCommentModel.getStats()
  const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats()

Severity: Major
Found in server/core/controllers/misc.ts - About 5 hrs to fix

    File server.ts has 395 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

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

      async function run () {
        await initDatabaseModels(true)
      
        const serverAccount = await getServerActor()
      
      
      Severity: Major
      Found in server/scripts/update-host.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

            File server-config-manager.ts has 383 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

              File users.ts has 379 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { forceNumber } from '@peertube/peertube-core-utils'
              import { HttpStatusCode, ServerErrorCode, UserRight, UserRole } from '@peertube/peertube-models'
              import express from 'express'
              import { body, param, query } from 'express-validator'
              import { exists, isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
              Severity: Minor
              Found in server/core/middlewares/validators/users/users.ts - About 5 hrs to fix

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

                import { DatePipe, NgClass, NgFor, NgIf } from '@angular/common'
                import { Component, OnInit, ViewChild } from '@angular/core'
                import { ActivatedRoute, Router, RouterLink } from '@angular/router'
                import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
                import { formatICU } from '@app/helpers'
                Severity: Minor
                Found in client/src/app/+admin/overview/videos/video-list.component.ts - About 5 hrs to fix

                  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 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

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

                        // Thanks https://github.com/streamroot/videojs-hlsjs-plugin
                        // We duplicated this plugin to choose the hls.js version we want, because streamroot only provide a bundled file
                        
                        import { logger } from '@root-helpers/logger'
                        import Hlsjs, { ErrorData, Level, LevelSwitchingData, ManifestParsedData } from 'hls.js'
                        Severity: Minor
                        Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 4 hrs to fix

                          Function buildPeerTubePlayerLoadOptions has 119 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 365 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 118 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

                                AccountModel has 35 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

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

                                  @Injectable()
                                  export class VideoService {
                                    static BASE_VIDEO_DOWNLOAD_URL = environment.originServerUrl + '/download/videos/generate'
                                    static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos'
                                    static BASE_FEEDS_URL = environment.apiUrl + '/feeds/videos.'
                                  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
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language