Showing 1,230 of 3,155 total issues
File constants.ts
has 1285 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { maxBy, minBy, randomInt } from '@peertube/peertube-core-utils'
import {
AbuseState,
AbuseStateType,
ActivityPubActorType,
File video-watch.component.ts
has 779 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { NgClass, NgIf, NgTemplateOutlet, PlatformLocation } from '@angular/common'
import { Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router, RouterLink } from '@angular/router'
import {
AuthService,
File config.ts
has 701 lines of code (exceeds 250 allowed). Consider refactoring. Open
import bytes from 'bytes'
import { IConfig } from 'config'
import { createRequire } from 'module'
import { dirname, join } from 'path'
import {
File video-redundancy.ts
has 690 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {
ActivityVideoUrlObject,
CacheFileObject,
FileRedundancyInformation,
StreamingPlaylistRedundancyInformation,
File video-comment.ts
has 666 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { pick } from '@peertube/peertube-core-utils'
import {
ActivityTagObject,
ActivityTombstoneObject,
UserRight,
File videos-id-list-query-builder.ts
has 586 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Sequelize, Transaction } from 'sequelize'
import validator from 'validator'
import { forceNumber } from '@peertube/peertube-core-utils'
import { VideoInclude, VideoIncludeType, VideoPrivacy, VideoPrivacyType, VideoState } from '@peertube/peertube-models'
import { exists } from '@server/helpers/custom-validators/misc.js'
Function getHTMLServerConfig
has 251 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getHTMLServerConfig (): Promise<HTMLServerConfig> {
if (this.serverCommit === undefined) this.serverCommit = await getServerCommit()
const serverActor = await getServerActor()
Function ngOnInit
has 244 lines of code (exceeds 25 allowed). Consider refactoring. Open
ngOnInit () {
this.serverConfig = this.serverService.getHTMLConfig()
const formGroupData: { [key in keyof ComponentCustomConfig ]: any } = {
instance: {
File video-stats.component.ts
has 564 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { ChartConfiguration, ChartData, ChartOptions, PluginOptionsByType, Scale, TooltipItem, defaults as ChartJSDefaults } from 'chart.js'
import zoomPlugin from 'chartjs-plugin-zoom'
import { Observable, of } from 'rxjs'
import { SelectOptionsItem } from 'src/types'
import { Component, Inject, LOCALE_ID, OnInit } from '@angular/core'
Function customConfig
has 234 lines of code (exceeds 25 allowed). Consider refactoring. Open
function customConfig (): CustomConfig {
return {
instance: {
name: CONFIG.INSTANCE.NAME,
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
Redis
has 59 functions (exceeds 20 allowed). Consider refactoring. Open
class Redis {
private static instance: Redis
private initialized = false
private connected = false
Function buildIdsListQuery
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
private buildIdsListQuery (options: BuildVideosListQueryOptions) {
this.attributes = options.attributes || [ '"video"."id"' ]
if (options.group) this.group = options.group
if (options.having) this.having = options.having
- Read upRead up
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
File video-edit.component.ts
has 515 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { DatePipe, NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common'
import { ChangeDetectorRef, Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
import { AbstractControl, FormArray, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'
import { HooksService, PluginService, ServerService } from '@app/core'
import { removeElementFromArray } from '@app/helpers'
File videos-command.ts
has 513 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
import validator from 'validator'
import { getAllPrivacies, omit, pick, wait } from '@peertube/peertube-core-utils'
import {
Function onFingerSwipe
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
onFingerSwipe (direction: 'left' | 'right' | 'up' | 'down', action: () => void, removeEventOnEnd = true) {
let touchDownClientX: number
let touchDownClientY: number
const onTouchStart = (event: TouchEvent) => {
- Read upRead up
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
File plugin-manager.ts
has 487 lines of code (exceeds 250 allowed). Consider refactoring. Open
import express from 'express'
import { createReadStream, createWriteStream } from 'fs'
import { ensureDir, outputFile, readJSON } from 'fs-extra/esm'
import { Server } from 'http'
import { createRequire } from 'module'
File video.service.ts
has 483 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { AuthService, ComponentPaginationLight, ConfirmService, RestExtractor, RestService, ServerService, UserService } from '@app/core'
import { objectToFormData } from '@app/helpers'
import { arrayify } from '@peertube/peertube-core-utils'
Function sanitize
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
protected sanitize (o: ImportObject) {
if (!isVideoNameValid(o.name)) return undefined
if (!isVideoDurationValid(o.duration + '')) return undefined
if (!isVideoChannelUsernameValid(o.channel?.name)) return undefined
if (!isVideoPrivacyValid(o.privacy)) return undefined
- Read upRead up
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
File live-manager.ts
has 466 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { pick, wait } from '@peertube/peertube-core-utils'
import {
ffprobePromise,
getVideoStreamBitrate,
getVideoStreamDimensionsInfo,
File videos.ts
has 454 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { arrayify } from '@peertube/peertube-core-utils'
import { HttpStatusCode, ServerErrorCode, UserRight, VideoState } from '@peertube/peertube-models'
import { Redis } from '@server/lib/redis.js'
import { buildUploadXFile, safeUploadXCleanup } from '@server/lib/uploadx.js'
import { getServerActor } from '@server/models/application/application.js'