feedsbrain/pssh-tools

View on GitHub

Showing 10 of 19 total issues

Function decodePssh has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

export const decodePssh = (data: string) => {
  const result: T.DecodeResult = {}
  const decodedData = Buffer.from(data, 'base64')

  // pssh header
Severity: Minor
Found in src/lib/pssh/tools.ts - About 6 hrs 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 decodePssh has 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const decodePssh = (data: string) => {
  const result: T.DecodeResult = {}
  const decodedData = Buffer.from(data, 'base64')

  // pssh header
Severity: Major
Found in src/lib/pssh/tools.ts - About 4 hrs to fix

    Function printPssh has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      result.printPssh = () => {
        // pssh version
        const psshArray = [`PSSH Box v${psshVersion}`]
    
        // system id
    Severity: Major
    Found in src/lib/pssh/tools.ts - About 2 hrs to fix

      Function getPsshHeader has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const getPsshHeader = (request: T.HeaderConfig): string => {
        const pssh = []
        const keyIds = request.keyIds || []
      
        // Set default to 0 for Widevine backward compatibility
      Severity: Minor
      Found in src/lib/pssh/tools.ts - About 1 hr to fix

        Function constructProXML has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const constructProXML = (keyPairs: T.KeyPair[], licenseUrl: string, keySeed: string, checksum: boolean = true): string => {
          const keyIds = keyPairs.map((k) => {
            return encodeKey(k, keySeed)
          })
          const xmlArray = ['<?xml version="1.0" encoding="UTF-8"?>']
        Severity: Minor
        Found in src/lib/pssh/playready.ts - About 1 hr to fix

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

          const getPsshData = (request: T.WidevineDataEncodeConfig) => {
            const protoFile = path.join(__dirname, 'proto', 'WidevineCencHeader.proto')
            const root = protobuf.loadSync(protoFile)
          
            const WidevineCencHeader = root.lookupType('proto.WidevineCencHeader')
          Severity: Minor
          Found in src/lib/pssh/widevine.ts - About 1 hr to fix

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

            export const getPsshHeader = (request: T.HeaderConfig): string => {
              const pssh = []
              const keyIds = request.keyIds || []
            
              // Set default to 0 for Widevine backward compatibility
            Severity: Minor
            Found in src/lib/pssh/tools.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 getPsshData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            const getPsshData = (request: T.WidevineDataEncodeConfig) => {
              const protoFile = path.join(__dirname, 'proto', 'WidevineCencHeader.proto')
              const root = protobuf.loadSync(protoFile)
            
              const WidevineCencHeader = root.lookupType('proto.WidevineCencHeader')
            Severity: Minor
            Found in src/lib/pssh/widevine.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 constructProXML has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            const constructProXML = (keyPairs: T.KeyPair[], licenseUrl: string, keySeed: string, checksum: boolean = true): string => {
              const keyIds = keyPairs.map((k) => {
                return encodeKey(k, keySeed)
              })
              const xmlArray = ['<?xml version="1.0" encoding="UTF-8"?>']
            Severity: Minor
            Found in src/lib/pssh/playready.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 getPsshData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            const getPsshData = (request: T.PlayReadyDataEncodeConfig): string => {
              const licenseUrl = request.licenseUrl || ''
              const keySeed = request.keySeed || ''
              const emptyKey = { key: '', kid: '' }
              const xmlData = request.compatibilityMode === true ? constructProXML4(request.keyPairs ? request.keyPairs[0] : emptyKey, licenseUrl, keySeed, request.checksum) : constructProXML(request.keyPairs ? request.keyPairs : [], licenseUrl, keySeed, request.checksum)
            Severity: Minor
            Found in src/lib/pssh/playready.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