Showing 1,292 of 3,313 total issues
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 server.ts
has 395 lines of code (exceeds 250 allowed). Consider refactoring. Open
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'
Function run
has 134 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function run () {
await initDatabaseModels(true)
const serverAccount = await getServerActor()
VideoCommentModel
has 40 functions (exceeds 20 allowed). Consider refactoring. Open
Open
@Scopes(() => ({
[ScopeNames.WITH_ACCOUNT]: {
include: [
{
model: AccountModel
PluginManager
has 40 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class PluginManager implements ServerHook {
private static instance: PluginManager
private registeredPlugins: { [name: string]: RegisteredPlugin } = {}
File server-config-manager.ts
has 383 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import {
HTMLServerConfig,
RegisteredExternalAuthConfig,
RegisteredIdAndPassAuthConfig,
ServerConfig,
File users.ts
has 379 lines of code (exceeds 250 allowed). Consider refactoring. Open
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'
File video-list.component.ts
has 378 lines of code (exceeds 250 allowed). Consider refactoring. Open
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'
File video-playlist.ts
has 368 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { forceNumber } from '@peertube/peertube-core-utils'
import {
HttpStatusCode,
VideoPlaylistCreate,
VideoPlaylistCreateResult,
File video-channel.ts
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import express from 'express'
import {
ActorImageType,
HttpStatusCode,
VideoChannelCreate,
Function getZanataContributors
has 119 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getZanataContributors () {
return [
{ username: 'abdhessuk', name: 'Abd Hessuk' },
{ username: 'abidin24', name: 'abidin toumi' },
{ username: 'aditoo', name: 'Lorem Ipsum' },
File hls-plugin.ts
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
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'
Function buildPeerTubePlayerLoadOptions
has 119 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private buildPeerTubePlayerLoadOptions (options: {
video: VideoDetails
liveVideo: LiveVideo
videoCaptions: VideoCaption[]
videoChapters: VideoChapter[]
File player-options-builder.ts
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { peertubeTranslate } from '@peertube/peertube-core-utils'
import {
HTMLServerConfig,
LiveVideo,
Storyboard,
Function getSelect
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private getSelect () {
return `SELECT
"UserNotificationModel"."id",
"UserNotificationModel"."type",
"UserNotificationModel"."read",
AccountModel
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
Open
@DefaultScope(() => ({
include: [
{
model: ActorModel, // Default scope includes avatar and server
required: true
VideoService
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
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.'
File user-moderation-dropdown.component.ts
has 352 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
Open
protected reloadDataInternal () {
debugLogger('Loading data.')
const options = {
pagination: this.pagination,
- 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
Function updateVideo
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
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