Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  async get (options: OverrideCommandOptions & {
    url: string

    videoFileToken?: string
    reinjectVideoFileToken?: boolean
Severity: Minor
Found in packages/server-commands/src/videos/streaming-playlists-command.ts - About 45 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 upload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  async upload (options: OverrideCommandOptions & {
    attributes?: VideoEdit
    mode?: 'legacy' | 'resumable' // default legacy
    waitTorrentGeneration?: boolean // default true
    completedExpectedStatus?: HttpStatusCodeType
Severity: Minor
Found in packages/server-commands/src/videos/videos-command.ts - About 45 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 timeToInt has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function timeToInt (time: number | string) {
  if (!time) return 0
  if (typeof time === 'number') return Math.floor(time)

  // Try with 00h00m00s format first
Severity: Minor
Found in packages/core-utils/src/common/date.ts - About 45 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 parseChapters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function parseChapters (text: string, maxTitleLength: number) {
  if (!text) return []

  const lines = text.split(/\r?\n|\r|\n/g)
  let foundChapters = false
Severity: Minor
Found in packages/core-utils/src/string/chapters.ts - About 45 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

Consider simplifying this complex logical expression.
Open

  if (
    (compacted.type === 'Create' && (compacted?.object?.type === 'WatchAction' || compacted?.object?.type === 'CacheFile')) ||
    (compacted.type === 'Undo' && compacted?.object?.type === 'Create' && compacted?.object?.object.type === 'CacheFile')
  ) {
    safe = false
Severity: Major
Found in server/core/helpers/peertube-jsonld.ts - About 40 mins to fix

    Function auditLoggerWrapper has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function auditLoggerWrapper (domain: string, user: string, action: AUDIT_TYPE, entity: EntityAuditView, oldEntity: EntityAuditView = null) {
    Severity: Minor
    Found in server/core/helpers/audit-logger.ts - About 35 mins to fix

      Function checkUserCanManageVideo has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      export function checkUserCanManageVideo (user: MUser, video: MVideoAccountLight, right: UserRightType, res: Response, onlyOwned = true) {
      Severity: Minor
      Found in server/core/middlewares/validators/shared/videos.ts - About 35 mins to fix

        Function updateCacheFile has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          cacheFileObject: CacheFileObject,
          redundancyModel: MVideoRedundancy,
          video: MVideoWithAllFiles,
          byActor: MActorId,
          t: Transaction
        Severity: Minor
        Found in server/core/lib/activitypub/cache-file.ts - About 35 mins to fix

          Function sendVideoRateChangeToOrigin has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            account: MAccountActor,
            video: MVideoAccountLight,
            likes: number,
            dislikes: number,
            t: Transaction
          Severity: Minor
          Found in server/core/lib/activitypub/video-rates.ts - About 35 mins to fix

            Function sendVideoRateChange has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              account: MAccountActor,
              video: MVideoFullLight,
              likes: number,
              dislikes: number,
              t: Transaction
            Severity: Minor
            Found in server/core/lib/activitypub/video-rates.ts - About 35 mins to fix

              Function defaultRender has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  const defaultRender = markdownIt.renderer.rules.link_open || function (tokens, idx, options, env, self) {
              Severity: Minor
              Found in client/src/app/core/renderer/markdown.service.ts - About 35 mins to fix

                Function link_open has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    markdownIt.renderer.rules.link_open = function (tokens, index, options, env, self) {
                Severity: Minor
                Found in client/src/app/core/renderer/markdown.service.ts - About 35 mins to fix

                  Function min has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function min (d0: number, d1: number, d2: number, bx: number, ay: number) {
                  Severity: Minor
                  Found in packages/transcription-devtools/src/levenshtein.ts - About 35 mins to fix

                    Function containsTags has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function containsTags (loggerTags: string[], optionsTags: string[]) {
                      if (!loggerTags) return false
                    
                      for (const lt of loggerTags) {
                        for (const ot of optionsTags) {
                    Severity: Minor
                    Found in server/scripts/parse-log.ts - About 35 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 toActivityPubObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      toActivityPubObject (this: MCommentAP, threadParentComments: MCommentOwner[]): VideoCommentObject | ActivityTombstoneObject {
                        const inReplyTo = this.inReplyToCommentId === null
                          ? this.Video.url // New thread, so we reply to the video
                          : this.InReplyToVideoComment.url
                    
                    
                    Severity: Minor
                    Found in server/core/models/video/video-comment.ts - About 35 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 buildMainQuery has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private buildMainQuery (options: BuildVideosListQueryOptions, serverActor: MActorAccount) {
                        this.attributes = {
                          '"video".*': ''
                        }
                    
                    
                    Severity: Minor
                    Found in server/core/models/video/sql/video/videos-model-list-query-builder.ts - About 35 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 migrate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function migrate () {
                      const tables = await sequelizeTypescript.getQueryInterface().showAllTables()
                    
                      // No tables, we don't need to migrate anything
                      // The installer will do that
                    Severity: Minor
                    Found in server/core/initializers/migrator.ts - About 35 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 checkEmailConfig has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function checkEmailConfig () {
                      if (!isEmailEnabled()) {
                        if (CONFIG.SIGNUP.ENABLED && CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) {
                          throw new Error('SMTP is not configured but you require signup email verification.')
                        }
                    Severity: Minor
                    Found in server/core/initializers/checker-after-init.ts - About 35 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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function run () {
                      console.log('Moving private video files in dedicated folders.')
                    
                      await ensureDir(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE)
                      await ensureDir(DIRECTORIES.WEB_VIDEOS.PRIVATE)
                    Severity: Minor
                    Found in server/scripts/migrations/peertube-5.0.ts - About 35 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 buildVideoExtMimetype has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function buildVideoExtMimetype (obj: { [ id: string ]: string | string[] }) {
                      const result: { [id: string]: string } = {}
                    
                      for (const mimetype of Object.keys(obj)) {
                        const value = obj[mimetype]
                    Severity: Minor
                    Found in server/core/initializers/constants.ts - About 35 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