Chocobozzz/PeerTube

View on GitHub

Showing 1,292 of 3,313 total issues

Function processVideo has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

async function processVideo (videoId: number) {
  const video = await VideoModel.loadWithFiles(videoId)

  const hls = video.getHLSPlaylist()
  if (video.isLive || !hls || hls.playlistFilename !== 'master.m3u8' || hls.VideoFiles.length === 0) {
Severity: Minor
Found in server/scripts/migrations/peertube-4.0.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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

async function run () {
  await initDatabaseModels(true)

  JobQueue.Instance.init()

Severity: Minor
Found in server/scripts/create-generate-storyboard-job.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 isPackageJSONValid has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function isPackageJSONValid (packageJSON: PluginPackageJSON, pluginType: PluginType_Type) {
  let result = true
  const badFields: string[] = []

  if (!isNpmPluginNameValid(packageJSON.name)) {
Severity: Minor
Found in server/core/helpers/custom-validators/plugins.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 generateVideoCaptionValidator has a Cognitive Complexity of 11 (exceeds 5 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

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

  private async makeAvailableFactory <T> (options: {
    createMethods: MakeAvailableCreateMethod[]
    cbContext: MakeAvailableMultipleCB<T>
  }) {
    const { cbContext, createMethods } = options
Severity: Minor
Found in server/core/lib/video-path-manager.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 updateObjectIfNeeded has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

async function updateObjectIfNeeded <T> (options: {
  url: string
  bodyValidator: (body: any) => boolean
  updater: (url: string, newUrl: string) => Promise<T>
  deleter: (url: string) => Promise<T> }
Severity: Minor
Found in server/core/lib/job-queue/handlers/activitypub-cleaner.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 crawlCollectionPage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) {
  let url = argUrl

  logger.info('Crawling ActivityPub data on %s.', url)

Severity: Minor
Found in server/core/lib/activitypub/crawl.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 buildMetadataFromVideo has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function buildMetadataFromVideo (video: MVideoThumbnail, type: ThumbnailType_Type, size?: ImageSize) {
  const existingThumbnail = Array.isArray(video.Thumbnails)
    ? video.Thumbnails.find(t => t.type === type)
    : undefined

Severity: Minor
Found in server/core/lib/thumbnail.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 resolveRemoteParentComment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

async function resolveRemoteParentComment (params: ResolveThreadParams) {
  const { url, comments } = params

  if (comments.length > ACTIVITY_PUB.MAX_RECURSION_COMMENTS) {
    throw new Error('Recursion limit reached when resolving a thread')
Severity: Minor
Found in server/core/lib/activitypub/video-comments.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 tryToResolveThreadFromVideo has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

async function tryToResolveThreadFromVideo (params: ResolveThreadParams) {
  const { url, comments, commentCreated } = params

  // Maybe it's a reply to a video?
  // If yes, it's done: we resolved all the thread
Severity: Minor
Found in server/core/lib/activitypub/video-comments.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 getP2PMediaLoaderOptions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  private getP2PMediaLoaderOptions (options: {
    redundancyUrlManager: RedundancyUrlManager | null
    segmentValidator: SegmentValidator | null
  }): HlsJsEngineSettings {
    const { redundancyUrlManager, segmentValidator } = options

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

  private loadVideo (options: {
    videoId: string
    forceAutoplay: boolean
    liveRefresh?: boolean
    videoPassword?: string
Severity: Minor
Found in client/src/app/+videos/+video-watch/video-watch.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 sendPendingChunks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  private async sendPendingChunks (): Promise<any> {
    if (this.ended) return Promise.resolve()

    const parallelPromises: Promise<any>[] = []

Severity: Minor
Found in apps/peertube-runner/src/server/process/shared/process-live.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 up has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function up (utils: {
  transaction: Sequelize.Transaction
  queryInterface: Sequelize.QueryInterface
  sequelize: Sequelize.Sequelize
  db: any
Severity: Minor
Found in server/core/initializers/migrations/0705-local-video-viewers.ts - About 1 hr to fix

    Function whereSearch has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private whereSearch (search?: string) {
        if (!search) {
          this.attributes.push('0 as similarity')
          return
        }
    Severity: Minor
    Found in server/core/models/video/sql/video/videos-id-list-query-builder.ts - About 1 hr to fix

      Function getVideoAttributes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        getVideoAttributes () {
          return [
            'id',
            'uuid',
            'name',
      Severity: Minor
      Found in server/core/models/video/sql/video/shared/video-table-attributes.ts - About 1 hr to fix

        Function up has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function up (utils: {
          transaction: Sequelize.Transaction
          queryInterface: Sequelize.QueryInterface
          sequelize: Sequelize.Sequelize
        }): Promise<void> {
        Severity: Minor
        Found in server/core/initializers/migrations/0865-video-file-streams.ts - About 1 hr to fix

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

            Function buildPlayerURLQuery has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function buildPlayerURLQuery (inputQueryUrl: string) {
              const allowedParameters = new Set([
                'start',
                'stop',
                'loop',
            Severity: Minor
            Found in server/core/controllers/services.ts - About 1 hr to fix

              Function getPluginValidator has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const getPluginValidator = (pluginType: PluginType_Type, withVersion = true) => {
                const validators: (ValidationChain | express.Handler)[] = [
                  param('pluginName')
                    .custom(isPluginNameValid)
                ]
              Severity: Minor
              Found in server/core/middlewares/validators/plugins.ts - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language