Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function setUserInfo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  setUserInfo (profile: UserUpdateMe) {
    const localStorageKeys = {
      nsfwPolicy: UserLocalStorageKeys.NSFW_POLICY,
      p2pEnabled: UserLocalStorageKeys.P2P_ENABLED,
      autoPlayVideo: UserLocalStorageKeys.AUTO_PLAY_VIDEO,
Severity: Minor
Found in client/src/app/core/users/user-local-storage.service.ts - About 1 hr to fix

    Function ngOnInit has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      ngOnInit () {
        this.serverConfig = this.serverService.getHTMLConfig()
    
        this.subActivatedRoute = this.route.queryParams
          .subscribe({
    Severity: Minor
    Found in client/src/app/+search/search.component.ts - About 1 hr to fix

      Function makeUploadRequest has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function makeUploadRequest (options: CommonRequestParams & {
        method?: 'POST' | 'PUT'
      
        fields: { [ fieldName: string ]: any }
        attaches?: { [ attachName: string ]: any | any[] }
      Severity: Minor
      Found in packages/server-commands/src/requests/requests.ts - About 1 hr to fix

        Function processJob has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export async function processJob (options: ProcessOptions) {
          const { server, job } = options
        
          logger.info(`[${server.url}] Processing job of type ${job.type}: ${job.uuid}`, { payload: job.payload })
        
        
        Severity: Minor
        Found in apps/peertube-runner/src/server/process/process.ts - About 1 hr to fix

          Function onStdout has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                this.app.stdout.on('data', function onStdout (data) {
                  let dontContinue = false
          
                  const log: string = data.toString()
                  aggregatedLogs += log
          Severity: Minor
          Found in packages/server-commands/src/server/server.ts - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                if (this.user && this.displayOptions.instanceUser && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) {
                  instanceActions = instanceActions.concat([
                    {
                      label: $localize`Edit user`,
                      description: $localize`Change quota, role, and more.`,

              Function checkTranscodingConfig has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function checkTranscodingConfig () {
                if (CONFIG.TRANSCODING.ENABLED) {
                  if (CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED === false && CONFIG.TRANSCODING.HLS.ENABLED === false) {
                    throw new Error('You need to enable at least Web Video transcoding or HLS transcoding.')
                  }
              Severity: Minor
              Found in server/core/initializers/checker-after-init.ts - About 55 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 checkStorageConfig has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function checkStorageConfig () {
                // Check storage directory locations
                if (isProdInstance()) {
                  const configStorage = config.get<{ [ name: string ]: string }>('storage')
              
              
              Severity: Minor
              Found in server/core/initializers/checker-after-init.ts - About 55 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 clear has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                private async clear (target: string) {
                  const redis = Redis.Instance.getClient()
              
                  if (target) {
                    clearTimeout(this.timers[target])
              Severity: Minor
              Found in server/core/middlewares/cache/shared/api-cache.ts - About 55 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 checkSignature has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              export async function checkSignature (req: Request, res: Response, next: NextFunction) {
                try {
                  const httpSignatureChecked = await checkHttpSignature(req, res)
                  if (httpSignatureChecked !== true) return
              
              
              Severity: Minor
              Found in server/core/middlewares/activitypub.ts - About 55 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 updateYoutubeDLBinary has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                static async updateYoutubeDLBinary () {
                  const url = CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE.URL
              
                  logger.info('Updating youtubeDL binary from %s.', url, lTags())
              
              
              Severity: Minor
              Found in server/core/helpers/youtube-dl/youtube-dl-cli.ts - About 55 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 searchVideoChannelURI has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              async function searchVideoChannelURI (search: string, res: express.Response) {
                let videoChannel: MChannelAccountDefault
                let uri = search
              
                if (!isURISearch(search)) {
              Severity: Minor
              Found in server/core/controllers/api/search/search-video-channels.ts - About 55 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 normalizeActor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              export function normalizeActor (actor: any) {
                if (!actor) return
              
                if (!actor.url) {
                  actor.url = actor.id
              Severity: Minor
              Found in server/core/helpers/custom-validators/activitypub/actor.ts - About 55 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 videoPlaylistsUpdateValidator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                  if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
              
                  if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return cleanUpReqFiles(req)
              
              
              Severity: Minor
              Found in server/core/middlewares/validators/videos/video-playlists.ts - About 55 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 usersUpdateMeValidator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                  const user = res.locals.oauth.token.User
              
                  if (req.body.password || req.body.email) {
                    if (user.pluginAuth !== null) {
              Severity: Minor
              Found in server/core/middlewares/validators/users/users.ts - About 55 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 usersAddValidator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                  if (areValidationErrors(req, res, { omitBodyLog: true })) return
                  if (!await checkUserNameOrEmailDoNotAlreadyExist(req.body.username, req.body.email, res)) return
              
                  const authUser = res.locals.oauth.token.User
              Severity: Minor
              Found in server/core/middlewares/validators/users/users.ts - About 55 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 checkCanSeeUserAuthVideo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              export async function checkCanSeeUserAuthVideo (options: {
                req: Request
                res: Response
                video: MVideoId | MVideoWithRights
              }) {
              Severity: Minor
              Found in server/core/middlewares/validators/shared/videos.ts - About 55 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 videosUpdateValidator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                  if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
                  if (areErrorsInScheduleUpdate(req, res)) return cleanUpReqFiles(req)
                  if (!await doesVideoExist(req.params.id, res)) return cleanUpReqFiles(req)
              
              
              Severity: Minor
              Found in server/core/middlewares/validators/videos/videos.ts - About 55 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 checkLiveSettingsReplayConsistency has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function checkLiveSettingsReplayConsistency (options: {
                res: express.Response
                body: LiveVideoUpdate
              }) {
                const { res, body } = options
              Severity: Minor
              Found in server/core/middlewares/validators/videos/video-live.ts - About 55 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 handleOAuthToken has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              async function handleOAuthToken (req: express.Request, options: { refreshTokenAuthName?: string, bypassLogin?: BypassLogin }) {
                const request = new Request(req)
                const { refreshTokenAuthName, bypassLogin } = options
              
                if (request.method !== 'POST') {
              Severity: Minor
              Found in server/core/lib/auth/oauth.ts - About 55 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