Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function parseBytes has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function parseBytes (value: string | number): number {
  if (typeof value === 'number') return value
  if (!isNaN(+value)) return +value

  const tgm = /^(\d+)\s*TB\s*(\d+)\s*GB\s*(\d+)\s*MB$/
Severity: Minor
Found in server/core/helpers/core-utils.ts - About 1 hr to fix

    Function buildFeedMetadata has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function buildFeedMetadata (options: {
      videoChannel?: MChannelBannerAccountDefault
      account?: MAccountDefault
      video?: MVideoFullLight
    }) {
    Severity: Minor
    Found in server/core/controllers/feeds/shared/common-feed-utils.ts - About 1 hr to fix

      Function handleTorrentImport has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function handleTorrentImport (req: express.Request, res: express.Response, torrentfile: Express.Multer.File) {
        const body: VideoImportCreate = req.body
        const user = res.locals.oauth.token.User
      
        let videoName: string
      Severity: Minor
      Found in server/core/controllers/api/videos/import.ts - About 1 hr to fix

        Function addLiveVideo has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function addLiveVideo (req: express.Request, res: express.Response) {
          const videoInfo: LiveVideoCreate = req.body
        
          const thumbnails = [ { type: ThumbnailType.MINIATURE, field: 'thumbnailfile' }, { type: ThumbnailType.PREVIEW, field: 'previewfile' } ]
            .map(({ type, field }) => {
        Severity: Minor
        Found in server/core/controllers/api/videos/live.ts - About 1 hr to fix

          Function createZip has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private createZip (options: {
              exportModel: MUserExport
              user: MUserDefault
              output: Writable
            }) {
          Severity: Minor
          Found in server/core/lib/user-import-export/user-exporter.ts - About 1 hr to fix

            Function generateLocalVideoMiniature has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function generateLocalVideoMiniature (options: {
              video: MVideoThumbnail
              videoFile: MVideoFile
              types: ThumbnailType_Type[]
              ffprobe: FfprobeData
            Severity: Minor
            Found in server/core/lib/thumbnail.ts - About 1 hr to fix

              Function buildTimeserieChartOptions has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private buildTimeserieChartOptions (rawData: VideoStatsTimeserie): ChartBuilderResult {
                  const labels: string[] = []
                  const data: number[] = []
              
                  for (const d of rawData.data) {
              Severity: Minor
              Found in client/src/app/+stats/video/video-stats.component.ts - About 1 hr to fix

                Function checkObjectStorageConfig has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function checkObjectStorageConfig () {
                  if (CONFIG.OBJECT_STORAGE.ENABLED !== true) return
                
                  if (!CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME) {
                    throw new Error('videos_bucket should be set when object storage support is enabled.')
                Severity: Minor
                Found in server/core/initializers/checker-after-init.ts - About 1 hr to fix

                  Function ngOnInit has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    ngOnInit () {
                      this.initialize()
                  
                      this.bulkActions = [
                        {

                    Function run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function run () {
                      await initDatabaseModels(true)
                    
                      const serverAccount = await getServerActor()
                    
                    
                    Severity: Minor
                    Found in server/scripts/update-host.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 videoStudioAddEditionValidator has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                        if (CONFIG.VIDEO_STUDIO.ENABLED !== true) {
                          res.fail({
                            status: HttpStatusCode.BAD_REQUEST_400,
                            message: 'Video studio is disabled on this instance'
                    Severity: Minor
                    Found in server/core/middlewares/validators/videos/video-studio.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 muxToMergeVideoFiles has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export async function muxToMergeVideoFiles (options: {
                      video: MVideoThumbnail
                      videoFiles: MVideoFile[]
                      output: Writable
                    }) {
                    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 processCreateVideoComment has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function processCreateVideoComment (
                      activity: ActivityCreate<VideoCommentObject | string>,
                      commentObject: VideoCommentObject,
                      byActor: MActorSignature,
                      fromFetch: false
                    Severity: Minor
                    Found in server/core/lib/activitypub/process/process-create.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 processVideo has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function processVideo (videoId: number) {
                      const video = await VideoModel.loadWithFiles(videoId)
                    
                      const hls = video.getHLSPlaylist()
                      if (video.isLive || !hls || hls.playlistFilename !== 'master.m3u8' || hls.VideoFiles.length === 0) {
                    Severity: Minor
                    Found in server/scripts/migrations/peertube-4.0.ts - About 1 hr to fix

                      Function isPackageJSONValid has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function isPackageJSONValid (packageJSON: PluginPackageJSON, pluginType: PluginType_Type) {
                        let result = true
                        const badFields: string[] = []
                      
                        if (!isNpmPluginNameValid(packageJSON.name)) {
                      Severity: Minor
                      Found in server/core/helpers/custom-validators/plugins.ts - About 1 hr to fix

                        Function addLocalViewer has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async addLocalViewer (options: {
                            video: MVideoImmutable
                            currentTime: number
                            ip: string
                            sessionId: string
                        Severity: Minor
                        Found in server/core/lib/views/shared/video-viewer-stats.ts - About 1 hr to fix

                          Function sendDeleteVideoComment has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          async function sendDeleteVideoComment (videoComment: MCommentOwnerVideo, transaction: Transaction) {
                            logger.info('Creating job to send delete of comment %s.', videoComment.url)
                          
                            const isVideoOrigin = videoComment.Video.isOwned()
                          
                          
                          Severity: Minor
                          Found in server/core/lib/activitypub/send/send-delete.ts - About 1 hr to fix

                            Function processVideoStudioEdition has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            async function processVideoStudioEdition (job: Job) {
                              const payload = job.data as VideoStudioEditionPayload
                              const lTags = lTagsBase(payload.videoUUID)
                            
                              logger.info('Process video studio edition of %s in job %s.', payload.videoUUID, job.id, lTags)
                            Severity: Minor
                            Found in server/core/lib/job-queue/handlers/video-studio-edition.ts - About 1 hr to fix

                              Function runStats has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                private runStats () {
                                  this.p2pEngine.on(Events.PieceBytesDownloaded, (method: string, _segment, bytes: number) => {
                                    const elem = method === 'p2p' ? this.statsP2PBytes : this.statsHTTPBytes
                              
                                    elem.pendingDownload.push(bytes)

                                Function buildModerationItems has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  private buildModerationItems () {
                                    const moderationItems: TopMenuDropdownParam = {
                                      label: $localize`Moderation`,
                                      children: []
                                    }
                                Severity: Minor
                                Found in client/src/app/+admin/admin.component.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language