Showing 1,188 of 3,041 total issues
VideosIdListQueryBuilder
has 47 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class VideosIdListQueryBuilder extends AbstractRunQuery {
protected replacements: any = {}
private attributes: string[]
private joins: string[] = []
File peertube-plugin.ts
has 437 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'
Function exports
has 159 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function () {
const configuration = {
entry: {
'video-embed': './src/standalone/videos/embed.ts',
'player': './src/standalone/embed-player-api/player.ts',
File client.ts
has 428 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import cors from 'cors'
import express from 'express'
import {
VideoChaptersObject,
VideoCommentObject,
Function sanitize
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
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 abuse-list-table.component.ts
has 423 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import * as 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 edit-custom-config.component.ts
has 422 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import omit from 'lodash-es/omit'
import { forkJoin } from 'rxjs'
import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
File config.ts
has 418 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import express from 'express'
import { remove, writeJSON } from 'fs-extra/esm'
import snakeCase from 'lodash-es/snakeCase.js'
import validator from 'validator'
import { ServerConfigManager } from '@server/lib/server-config-manager.js'
File video-actions-dropdown.component.ts
has 412 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { NgIf } from '@angular/common'
import { Component, EventEmitter, Input, OnChanges, Output, ViewChild, booleanAttribute } from '@angular/core'
import { AuthService, ConfirmService, Notifier, ScreenService, ServerService } from '@app/core'
import { NgbDropdown, NgbDropdownAnchor, NgbDropdownMenu } from '@ng-bootstrap/ng-bootstrap'
import { VideoCaption } from '@peertube/peertube-models'
File peertube-player.ts
has 410 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import '@peertube/videojs-contextmenu'
import './shared/upnext/end-card'
import './shared/upnext/upnext-plugin'
import './shared/stats/stats-card'
import './shared/stats/stats-plugin'
File users.ts
has 407 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import express from 'express'
import { body, param, query } from 'express-validator'
import { forceNumber } from '@peertube/peertube-core-utils'
import { HttpStatusCode, UserRight, UserRole } from '@peertube/peertube-models'
import { exists, isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
VideoWatchComponent
has 42 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,
VideosCommand
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class VideosCommand extends AbstractCommand {
getCategories (options: OverrideCommandOptions = {}) {
const path = '/api/v1/videos/categories'
Function run
has 141 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function run () {
console.log('Preparing server...')
await prepare()
Function buildIdsListQuery
has 140 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 generateNodeinfo
has 139 lines of code (exceeds 25 allowed). Consider refactoring. Open
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()
File account.ts
has 398 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { FindOptions, Includeable, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize'
import {
AllowNull,
BeforeDestroy,
BelongsTo,
File muxing-session.ts
has 397 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { wait } from '@peertube/peertube-core-utils'
import { FileStorage, LiveVideoError, VideoStreamingPlaylistType } from '@peertube/peertube-models'
import { computeOutputFPS } from '@server/helpers/ffmpeg/index.js'
import { LoggerTagsFn, logger, loggerTagsFactory } from '@server/helpers/logger.js'
import { CONFIG } from '@server/initializers/config.js'
Function run
has 134 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function run () {
await initDatabaseModels(true)
const serverAccount = await getServerActor()
File config-command.ts
has 389 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'