Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

Function buildAdditionalAttributes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function buildAdditionalAttributes (video: MVideoFormattable, options: VideoFormattingJSONOptions) {
  const add = options.additionalAttributes

  const result: Partial<VideoAdditionalAttributes> = {}

Severity: Minor
Found in server/core/models/video/formatter/video-api-format.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 checkMissedConfig has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function checkMissedConfig () {
  const required = [ 'listen.port', 'listen.hostname',
    'webserver.https', 'webserver.hostname', 'webserver.port',
    'secrets.peertube',
    'trust_proxy',
Severity: Minor
Found in server/core/initializers/checker-before-init.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 generateOutput has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

async function generateOutput (options: {
  startDateQuery: string
  endDateQuery?: string

  level: ServerLogLevel
Severity: Minor
Found in server/core/controllers/api/server/logs.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 buildFeedMetadata has a Cognitive Complexity of 12 (exceeds 5 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

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 isValidPasswordProtectedPrivacy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function isValidPasswordProtectedPrivacy (req: Request, res: Response) {
  const fail = (message: string) => {
    res.fail({
      status: HttpStatusCode.BAD_REQUEST_400,
      message
Severity: Minor
Found in server/core/helpers/custom-validators/videos.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 filter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  filter: async function (infoHash, params, cb) {
    if (CONFIG.TRACKER.ENABLED === false) {
      return cb(new Error('Tracker is disabled on this instance.'))
    }

Severity: Minor
Found in server/core/controllers/tracker.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 handlePasswordGrant has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

async function handlePasswordGrant (options: {
  request: Request
  client: MOAuthClient
  bypassLogin?: BypassLogin
}) {
Severity: Minor
Found in server/core/lib/auth/oauth.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 saveNewOriginalFileIfNeeded has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export async function saveNewOriginalFileIfNeeded (video: MVideo, videoFile: MVideoFile) {
  if (!CONFIG.TRANSCODING.ORIGINAL_FILE.KEEP) return

  const videoSource = await VideoSourceModel.loadLatest(video.id)

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 export has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  async export (exportModel: MUserExport) {
    try {
      exportModel.state = UserExportState.PROCESSING
      await saveInTransactionWithRetries(exportModel)

Severity: Minor
Found in server/core/lib/user-import-export/user-exporter.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 computeResolutionsToTranscode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function computeResolutionsToTranscode (options: {
  input: number
  type: 'vod' | 'live'
  includeInput: boolean
  strictLower: boolean
Severity: Minor
Found in server/core/lib/transcoding/transcoding-resolutions.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 processVideoStudioEdition has a Cognitive Complexity of 12 (exceeds 5 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

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 getOrCreateAPActor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

async function getOrCreateAPActor (
  activityActor: string | ActivityPubActor,
  fetchType: ActorLoadByUrlType = 'association-ids',
  recurseIfNeeded = true,
  updateCollections = false
Severity: Minor
Found in server/core/lib/activitypub/actors/get.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 runUserViewing has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  private runUserViewing () {
    const startTime = timeToInt(this.options.startTime())

    let lastCurrentTime = startTime
    let lastViewEvent: VideoViewEvent
Severity: Minor
Found in client/src/assets/player/shared/peertube/peertube-plugin.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 buildParamsFromSearch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  private buildParamsFromSearch (search: string, params: HttpParams) {
    const filters = this.restService.parseQueryStringFilter(search, {
      stateOneOf: {
        prefix: 'state:',
        multiple: true,
Severity: Minor
Found in client/src/app/+admin/system/runners/runner.service.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 size has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  size () {
    let acc = 0

    if (this.isValidValue(this.startDate) || this.isValidValue(this.endDate)) acc++
    if (this.isValidValue(this.originallyPublishedStartDate) || this.isValidValue(this.originallyPublishedEndDate)) acc++
Severity: Minor
Found in client/src/app/shared/shared-search/advanced-search.model.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 buildVideoAttributesFromCommander has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

async function buildVideoAttributesFromCommander (server: PeerTubeServer, options: UploadOptions) {
  const defaultBooleanAttributes = {
    nsfw: false,
    downloadEnabled: true,
    waitTranscoding: true
Severity: Minor
Found in apps/peertube-cli/src/peertube-upload.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 up has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function up (utils: {
  transaction: Sequelize.Transaction
  queryInterface: Sequelize.QueryInterface
  sequelize: Sequelize.Sequelize
  db: any
Severity: Minor
Found in server/core/initializers/migrations/0750-user-registration.ts - About 1 hr to fix

    Function videoModelToFormattedDetailsJSON has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): VideoDetails {
      const span = tracer.startSpan('peertube.VideoModel.toFormattedDetailsJSON')
    
      const videoJSON = video.toFormattedJSON({
        completeDescription: true,
    Severity: Minor
    Found in server/core/models/video/formatter/video-api-format.ts - About 1 hr to fix

      Function up has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function up (utils: {
        transaction: Sequelize.Transaction
        queryInterface: Sequelize.QueryInterface
        sequelize: Sequelize.Sequelize
        db: any
      Severity: Minor
      Found in server/core/initializers/migrations/0685-multiple-actor-images.ts - About 1 hr to fix

        Function updateVideoChannel has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function updateVideoChannel (req: express.Request, res: express.Response) {
          const videoChannelInstance = res.locals.videoChannel
          const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON())
          const videoChannelInfoToUpdate = req.body as VideoChannelUpdate
          let doBulkVideoUpdate = false
        Severity: Minor
        Found in server/core/controllers/api/video-channel.ts - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language