Showing 1,292 of 3,313 total issues
File peertube-plugin.ts
has 469 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { timeToInt } from '@peertube/peertube-core-utils'
import { VideoView, VideoViewEvent } from '@peertube/peertube-models'
import { logger } from '@root-helpers/logger'
import { isIOS, isMobile, isSafari } from '@root-helpers/web-browser'
import debug from 'debug'
File config-command.ts
has 464 lines of code (exceeds 250 allowed). Consider refactoring. Open
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'
File videos.ts
has 458 lines of code (exceeds 250 allowed). Consider refactoring. Open
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'
File job-queue.ts
has 456 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { pick, timeoutPromise } from '@peertube/peertube-core-utils'
import {
ActivitypubFollowPayload,
ActivitypubHttpBroadcastPayload,
ActivitypubHttpFetcherPayload,
VideosIdListQueryBuilder
has 48 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class VideosIdListQueryBuilder extends AbstractRunQuery {
protected replacements: any = {}
private attributes: string[]
private joins: string[] = []
File client.ts
has 443 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import {
HttpStatusCode,
VideoChaptersObject,
VideoCommentObject,
VideoPlaylistPrivacy,
File account.ts
has 435 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { Account, AccountSummary, VideoPrivacy } from '@peertube/peertube-models'
import { ModelCache } from '@server/models/shared/model-cache.js'
import { FindOptions, IncludeOptions, Includeable, Op, Transaction, WhereOptions, literal } from 'sequelize'
import {
AfterDestroy,
File edit-custom-config.component.ts
has 435 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { NgFor, NgIf } from '@angular/common'
import { Component, OnInit } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { ActivatedRoute, Router } from '@angular/router'
import { ConfigService } from '@app/+admin/config/shared/config.service'
File config.ts
has 432 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { About, ActorImageType, ActorImageType_Type, CustomConfig, HttpStatusCode, UserRight } from '@peertube/peertube-models'
import { createReqFiles } from '@server/helpers/express-utils.js'
import { MIMETYPES } from '@server/initializers/constants.js'
import { deleteLocalActorImageFile, updateLocalActorImageFiles } from '@server/lib/local-actor.js'
import { ServerConfigManager } from '@server/lib/server-config-manager.js'
File abuse-list-table.component.ts
has 423 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import debug from 'debug'
import { SortMeta, SharedModule } from 'primeng/api'
import { Component, Input, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core'
File muxing-session.ts
has 422 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { wait } from '@peertube/peertube-core-utils'
import {
FileStorage,
LiveVideoError,
VideoFileFormatFlag,
Function buildActions
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private buildActions () {
this.videoActions = [
[
{
label: $localize`Save to playlist`,
ConfigCommand
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class ConfigCommand extends AbstractCommand {
static getConfigResolutions (enabled: boolean, with0p = false) {
return {
'0p': enabled && with0p,
VideosCommand
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class VideosCommand extends AbstractCommand {
getCategories (options: OverrideCommandOptions = {}) {
const path = '/api/v1/videos/categories'
Function sanitizeAndCheckVideoTorrentObject
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
Open
export function sanitizeAndCheckVideoTorrentObject (video: VideoObject) {
if (!video || video.type !== 'Video') return false
const fail = (field: string) => {
logger.debug(`Video field is not valid to PeerTube: ${field}`, { video })
- 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
VideoWatchComponent
has 43 functions (exceeds 20 allowed). Consider refactoring. Open
Open
@Component({
selector: 'my-video-watch',
templateUrl: './video-watch.component.html',
styleUrls: [ './video-watch.component.scss' ],
standalone: true,
File peertube-player.ts
has 409 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import './shared/context-menu'
import './shared/upnext/end-card'
import './shared/upnext/upnext-plugin'
import './shared/stats/stats-card'
import './shared/stats/stats-plugin'
Function buildIdsListQuery
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function run
has 141 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function run () {
console.log('Preparing server...')
await prepare()
File videos-list.component.ts
has 400 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common'
import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, booleanAttribute } from '@angular/core'
import { ActivatedRoute, RouterLink, RouterLinkActive } from '@angular/router'
import {
AuthService,