Chocobozzz/PeerTube

View on GitHub

Showing 1,211 of 3,123 total issues

Function init has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  init () {
    // Already initialized
    if (this.initialized === true) return
    this.initialized = true

Severity: Minor
Found in server/core/lib/emailer.ts - About 25 mins 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 processCreateAbuse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function processCreateAbuse (flag: ActivityFlag, byActor: MActorSignature) {
  const account = byActor.Account
  if (!account) throw new Error('Cannot create abuse with the non account actor ' + byActor.url)

  const reporterAccount = await AccountModel.load(account.id)
Severity: Minor
Found in server/core/lib/activitypub/process/process-flag.ts - About 25 mins 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 internalExecute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  protected async internalExecute () {
    const videoIds = await Redis.Instance.listLocalVideosViewed()
    if (videoIds.length === 0) return

    for (const videoId of videoIds) {
Severity: Minor
Found in server/core/lib/schedulers/video-views-buffer-scheduler.ts - About 25 mins 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 createTranscodingJobs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async createTranscodingJobs (options: {
    transcodingType: 'hls' | 'webtorrent' | 'web-video' // TODO: remove webtorrent in v7
    video: MVideoFullLight
    resolutions: number[]
    isNewVideo: boolean

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

export function canVideoBeFederated (video: MVideoWithBlacklistRights, isNewVideo = false) {
  // Check this is not a blacklisted video
  if (video.isBlacklisted() === true) {
    if (isNewVideo === false) return false
    if (video.VideoBlacklist.unfederated === true) return false
Severity: Minor
Found in server/core/lib/activitypub/videos/federate.ts - About 25 mins 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 refreshVideoPlaylistIfNeeded has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function refreshVideoPlaylistIfNeeded (videoPlaylist: MVideoPlaylistOwner): Promise<MVideoPlaylistOwner> {
  if (!videoPlaylist.isOutdated()) return videoPlaylist

  const lTags = loggerTagsFactory('ap', 'video-playlist', 'refresh', videoPlaylist.uuid, videoPlaylist.url)

Severity: Minor
Found in server/core/lib/activitypub/playlists/refresh.ts - About 25 mins 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 updateVideos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private async updateVideos () {
    if (!await ScheduleVideoUpdateModel.areVideosToUpdate()) return undefined

    const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate()

Severity: Minor
Found in server/core/lib/schedulers/update-videos-scheduler.ts - About 25 mins 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 buildAvailableProfiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private buildAvailableProfiles () {
    for (const type of [ 'vod', 'live' ]) {
      const result = new Set()

      const encoders = this.availableEncoders[type]
Severity: Minor
Found in server/core/lib/transcoding/default-transcoding-profiles.ts - About 25 mins 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 buildSystemItems has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private buildSystemItems () {
    const systemItems: TopMenuDropdownParam = {
      label: $localize`System`,
      children: []
    }
Severity: Minor
Found in client/src/app/+admin/admin.component.ts - About 25 mins 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 onDoubleTap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private onDoubleTap (event: TouchEvent) {
    const playerWidth = this.player.currentWidth()

    const rect = this.findPlayerTarget((event.target as HTMLElement)).getBoundingClientRect()
    const offsetX = event.targetTouches[0].pageX - rect.left
Severity: Minor
Found in client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts - About 25 mins 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 ngOnInit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  ngOnInit () {
    if (this.localStorage.getItem(this.localStorageHotkeysDisabledKey) === 'true') {
      this.hotkeysEnabled = false
      this.hotkeysService.disableHotkeys()
    }
Severity: Minor
Found in client/src/app/hotkeys/hotkeys-cheat-sheet.component.ts - About 25 mins 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 getLatinKey has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private getLatinKey (key: string, code: string) {
    if (key.length !== 1) {
      return key
    }

Severity: Minor
Found in client/src/assets/player/shared/hotkeys/peertube-hotkeys-plugin.ts - About 25 mins 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 buildHotkeysHelp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private buildHotkeysHelp (video: Video) {
    if (this.hotkeys.length !== 0) {
      this.hotkeysService.remove(this.hotkeys)
    }

Severity: Minor
Found in client/src/app/+videos/+video-watch/video-watch.component.ts - About 25 mins 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 _onError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private _onError (_event: any, data: ErrorData) {
    const error: { message: string, code?: number } = {
      message: `HLS.js error: ${data.type} - fatal: ${data.fatal} - ${data.details}`
    }

Severity: Minor
Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 25 mins 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 checkAndConfirmVideoFileReplacement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private async checkAndConfirmVideoFileReplacement () {
    const replaceFile: File = this.form.value['replaceFile']
    if (!replaceFile) return true

    const user = this.auth.getUser()
Severity: Minor
Found in client/src/app/+videos/+video-edit/video-update.component.ts - About 25 mins 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 buildAvailableVideo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private buildAvailableVideo (li: HTMLElement, positionBlock: HTMLElement, options: PlaylistItemOptions) {
    const videoElement = options.element

    const player = super.createEl('div', {
      className: 'item-player'
Severity: Minor
Found in client/src/assets/player/shared/playlist/playlist-menu-item.ts - About 25 mins 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 getPluginOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async getPluginOptions () {
    const redundancyUrlManager = new RedundancyUrlManager(this.options.hls.redundancyBaseUrls)
    const segmentValidator = new SegmentValidator({
      segmentsSha256Url: this.options.hls.segmentsSha256Url,
      authorizationHeader: this.options.authorizationHeader,

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

function toBoolean (value: any) {
  if (!value) return undefined

  if (typeof value === 'boolean') return value

Severity: Minor
Found in client/src/app/helpers/utils/object.ts - About 25 mins 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 buildMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function buildMessage (name: string, err: Pick<HttpErrorResponse, 'message' | 'status' | 'headers'>) {
  if (err instanceof ErrorEvent) { // network error
    return $localize`The connection was interrupted`
  }

Severity: Minor
Found in client/src/app/helpers/utils/upload.ts - About 25 mins 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 getChapter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  getChapter (timecode: number) {
    if (this.chapters.length !== 0) {
      for (let i = this.chapters.length - 1; i >= 0; i--) {
        const chapter = this.chapters[i]

Severity: Minor
Found in client/src/assets/player/shared/control-bar/chapters-plugin.ts - About 25 mins 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

Severity
Category
Status
Source
Language