Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Avoid too many return statements within this function.
Open

  return true
Severity: Major
Found in packages/ffmpeg/src/ffmpeg-default-transcoding-profile.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

      if (bitRate > getMaxTheoreticalBitrate({ ...resolutionData, fps })) return false
    Severity: Major
    Found in packages/ffmpeg/src/ffmpeg-default-transcoding-profile.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

        return result
      Severity: Major
      Found in packages/core-utils/src/common/date.ts - About 30 mins to fix

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

        async function createOAuthAdminIfNotExist () {
          const exist = await usersExist()
          // Nothing to do, users already exist
          if (exist === true) return undefined
        
        
        Severity: Minor
        Found in server/core/initializers/installer.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 buildVideoFileUrls has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function buildVideoFileUrls (options: {
          video: MVideo
          files: MVideoFile[]
          user?: MUserId
        }): ActivityUrlObject[] {
        Severity: Minor
        Found in server/core/models/video/formatter/video-activity-pub-format.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 checkRemovedConfigKeys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function checkRemovedConfigKeys () {
          // Moved configuration keys
          if (config.has('services.csp-logger')) {
            logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
          }
        Severity: Minor
        Found in server/core/initializers/checker-after-init.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 toFormattedJSONStatic has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          static toFormattedJSONStatic (video: MVideoForRedundancyAPI): VideoRedundancy {
            const filesRedundancies: FileRedundancyInformation[] = []
            const streamingPlaylistsRedundancies: StreamingPlaylistRedundancyInformation[] = []
        
            for (const file of video.VideoFiles) {
        Severity: Minor
        Found in server/core/models/redundancy/video-redundancy.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function run () {
          await initDatabaseModels(true)
        
          displayPeerTubeMustBeStoppedWarning()
        
        
        Severity: Minor
        Found in server/scripts/update-object-storage-url.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 checkFFmpeg has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
          if (CONFIG.TRANSCODING.ENABLED === false) return undefined
        
          const Ffmpeg = (await import('fluent-ffmpeg')).default
          const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs)
        Severity: Minor
        Found in server/core/initializers/checker-before-init.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 checkFFmpegVersion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function checkFFmpegVersion () {
          const version = await getFFmpegVersion()
          const semvar = parseSemVersion(version)
        
          if (!semvar) {
        Severity: Minor
        Found in server/core/initializers/checker-after-init.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 downloadGeneratedVideoFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function downloadGeneratedVideoFile (req: express.Request, res: express.Response) {
          const video = res.locals.videoAll
          const filesToSelect = req.query.videoFileIds
        
          const videoFiles = video.getAllFiles()
        Severity: Minor
        Found in server/core/controllers/download.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 convertCustomConfigBody has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function convertCustomConfigBody (body: CustomConfig) {
          function keyConverter (k: string) {
            // Transcoding resolutions exception
            if (/^\d{3,4}p$/.exec(k)) return k
            if (k === '0p') return k
        Severity: Minor
        Found in server/core/controllers/api/config.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 videoCommentController has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function videoCommentController (req: express.Request, res: express.Response) {
          const videoComment = res.locals.videoCommentFull
        
          if (redirectIfNotOwned(videoComment.url, res)) return
          if (videoComment.Video.isOwned() && videoComment.heldForReview === true) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
        Severity: Minor
        Found in server/core/controllers/activitypub/client.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 handleTorrentImport has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function handleTorrentImport (req: express.Request, res: express.Response, torrentfile: Express.Multer.File) {
          const body: VideoImportCreate = req.body
          const user = res.locals.oauth.token.User
        
          let videoName: string
        Severity: Minor
        Found in server/core/controllers/api/videos/import.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 isWatchActionObjectValid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function isWatchActionObjectValid (action: WatchActionObject) {
          if (!action || action.type !== 'WatchAction') return false
        
          // TODO: compat with < 6.1, remove in 7.0
          if (!action.uuid && action['identifier']) action.uuid = action['identifier']
        Severity: Minor
        Found in server/core/helpers/custom-validators/activitypub/watch-action.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 searchVideosIndex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function searchVideosIndex (query: VideosSearchQueryAfterSanitize, res: express.Response) {
          const result = await buildMutedForSearchIndex(res)
        
          let body = { ...query, ...result }
        
        
        Severity: Minor
        Found in server/core/controllers/api/search/search-videos.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 normalizeObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          private normalizeObject (obj: any) {
            const newObj: any = {}
        
            for (const key of Object.keys(obj)) {
              // Deprecated key
        Severity: Minor
        Found in server/core/helpers/youtube-dl/youtube-dl-info-builder.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 updateUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function updateUser (req: express.Request, res: express.Response) {
          const body: UserUpdate = req.body
          const userToUpdate = res.locals.user
          const byUser = res.locals.oauth.token.User
          const oldUserAuditView = new UserAuditView(userToUpdate.toFormattedJSON())
        Severity: Minor
        Found in server/core/controllers/api/users/index.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 getCategory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          private getCategory (categories: string[]) {
            if (!categories) return undefined
        
            const categoryString = categories[0]
            if (!categoryString || typeof categoryString !== 'string') return undefined
        Severity: Minor
        Found in server/core/helpers/youtube-dl/youtube-dl-info-builder.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 updateReplaySettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function updateReplaySettings (videoLive: MVideoLive, body: LiveVideoUpdate) {
          if (exists(body.saveReplay)) videoLive.saveReplay = body.saveReplay
        
          // The live replay is not saved anymore, destroy the old model if it existed
          if (!videoLive.saveReplay) {
        Severity: Minor
        Found in server/core/controllers/api/videos/live.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