Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

Function importObject has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  protected async importObject (channelImportData: SanitizedObject) {
    const account = this.user.Account
    const existingChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(channelImportData.name)

    if (existingChannel) {
Severity: Minor
Found in server/core/lib/user-import-export/importers/channels-importer.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 createTranscodingJobs has a Cognitive Complexity of 13 (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 disposeDynamicPluginsIfNeeded has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  private disposeDynamicPluginsIfNeeded () {
    if (!this.player) return

    if (this.player.usingPlugin('peertubeMobile')) this.player.peertubeMobile().dispose()
    if (this.player.usingPlugin('peerTubeHotkeysPlugin')) this.player.peerTubeHotkeysPlugin().dispose()
Severity: Minor
Found in client/src/assets/player/peertube-player.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 update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  async update () {
    await this.waitPendingCheck()
    this.forceCheck()

    if (!this.form.valid || this.isUpdatingVideo === true) return
Severity: Minor
Found in client/src/app/+videos/+video-edit/video-update.component.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 objectToFormData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function objectToFormData (obj: any, form?: FormData, namespace?: string) {
  const fd = form || new FormData()
  let formKey

  for (const key of Object.keys(obj)) {
Severity: Minor
Found in client/src/app/helpers/utils/url.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 getEncoderBuilderResult has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  async getEncoderBuilderResult (options: EncoderOptionsBuilderParams & {
    streamType: 'video' | 'audio'
    input: string

    videoType: 'vod' | 'live'
Severity: Minor
Found in packages/ffmpeg/src/ffmpeg-command-wrapper.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 buildFields has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function buildFields (req: request.Test, fields: { [ fieldName: string ]: any }, namespace?: string) {
  if (!fields) return

  let formKey: string

Severity: Minor
Found in packages/server-commands/src/requests/requests.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 toFormattedJSONStatic has 39 lines of code (exceeds 25 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 1 hr to fix

    Function run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function run () {
      console.log('Generate avatar miniatures from existing avatars.')
    
      await initDatabaseModels(true)
      JobQueue.Instance.init()
    Severity: Minor
    Found in server/scripts/migrations/peertube-4.2.ts - About 1 hr to fix

      Function buildVideoFileUrls has 39 lines of code (exceeds 25 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 1 hr to fix

        Function buildOEmbed has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function buildOEmbed (options: {
          req: express.Request
          title: string
          channel: MChannelSummary
          previewPath: string | null
        Severity: Minor
        Found in server/core/controllers/services.ts - About 1 hr to fix

          Function createVideoPlaylist has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function createVideoPlaylist (req: express.Request, res: express.Response) {
            const videoPlaylistInfo: VideoPlaylistCreate = req.body
            const user = res.locals.oauth.token.User
          
            const videoPlaylist = new VideoPlaylistModel({
          Severity: Minor
          Found in server/core/controllers/api/video-playlist.ts - About 1 hr to fix

            Function usersCommonRegistrationValidatorFactory has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function usersCommonRegistrationValidatorFactory (additionalValidationChain: ValidationChain[] = []) {
              return [
                body('username')
                  .custom(isUserUsernameValid),
                body('password')
            Severity: Minor
            Found in server/core/middlewares/validators/users/user-registrations.ts - About 1 hr to fix

              Function generateVideoCaptionValidator has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                  if (areValidationErrors(req, res)) return
              
                  if (CONFIG.VIDEO_TRANSCRIPTION.ENABLED !== true) {
                    return res.fail({
              Severity: Minor
              Found in server/core/middlewares/validators/videos/video-captions.ts - About 1 hr to fix

                Function getAccountOrChannelHTMLPage has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private static async getAccountOrChannelHTMLPage (
                    loader: () => Promise<MAccountHost | MChannelHost>,
                    req: express.Request,
                    res: express.Response
                  ) {
                Severity: Minor
                Found in server/core/lib/html/shared/actor-html.ts - About 1 hr to fix

                  Function handleOAuthToken has 39 lines of code (exceeds 25 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 1 hr to fix

                    Function buildMuxInput has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function buildMuxInput (
                      video: MVideo,
                      videoFile: MVideoFile
                    ): Promise<{ input: Readable, isTmpDestination: false } | { input: string, isTmpDestination: boolean }> {
                    
                    
                    Severity: Minor
                    Found in server/core/lib/video-file.ts - About 1 hr to fix

                      Function mergeAudioVideofile has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export async function mergeAudioVideofile (options: {
                        video: MVideoFullLight
                        resolution: number
                        fps: number
                        job: Job
                      Severity: Minor
                      Found in server/core/lib/transcoding/web-transcoding.ts - About 1 hr to fix

                        Function processCreateVideoComment has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        async function processCreateVideoComment (
                          activity: ActivityCreate<VideoCommentObject | string>,
                          commentObject: VideoCommentObject,
                          byActor: MActorSignature,
                          fromFetch: false
                        Severity: Minor
                        Found in server/core/lib/activitypub/process/process-create.ts - About 1 hr to fix

                          Function getFileAttributesFromUrl has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function getFileAttributesFromUrl (
                            videoOrPlaylist: MVideo | MStreamingPlaylistVideo,
                            urls: (ActivityTagObject | ActivityUrlObject)[]
                          ) {
                            const fileUrls = urls.filter(u => isAPVideoUrlObject(u))
                            Severity
                            Category
                            Status
                            Source
                            Language