feedsbrain/pssh-tools

View on GitHub

Showing 19 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

            Emphasis used instead of a header
            Open

            **Tools to generate PSSH Data and PSSH Box**
            Severity: Info
            Found in README.md by markdownlint

            MD036 - Emphasis used instead of a header

            Tags: headers, emphasis

            Parameters: punctuation (string; default ".,;:!?")

            Aliases: no-emphasis-as-header

            This check looks for instances where emphasized (i.e. bold or italic) text is used to separate sections, where a header should be used instead:

            **My document**
            
            Lorem ipsum dolor sit amet...
            
            _Another section_
            
            Consectetur adipiscing elit, sed do eiusmod.

            To fix this, use markdown headers instead of emphasized text to denote sections:

            # My document
            
            Lorem ipsum dolor sit amet...
            
            ## Another section
            
            Consectetur adipiscing elit, sed do eiusmod.

            Note: this rule looks for single line paragraphs that consist entirely of emphasized text. It won't fire on emphasis used within regular text, multi-line emphasized paragraphs, and paragraphs ending in punctuation. Similarly to rule MD026, you can configure what characters are recognized as punctuation.

            Line length
            Open

            [![Build Status](https://travis-ci.org/feedsbrain/pssh-tools.svg?branch=master)](https://travis-ci.org/feedsbrain/pssh-tools) [![Maintainability](https://api.codeclimate.com/v1/badges/916d04bffb3000cbda7d/maintainability)](https://codeclimate.com/github/feedsbrain/pssh-tools/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/916d04bffb3000cbda7d/test_coverage)](https://codeclimate.com/github/feedsbrain/pssh-tools/test_coverage)
            Severity: Info
            Found in README.md by markdownlint

            MD013 - Line length

            Tags: line_length

            Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

            This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

            This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

            You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

            Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

            Line length
            Open

            Currently we're only focus on Widevine and PlayReady but we will support more in the future.
            Severity: Info
            Found in README.md by markdownlint

            MD013 - Line length

            Tags: line_length

            Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

            This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

            This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

            You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

            Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

            Line length
            Open

            For dealing with multi-drm using common encryption (cenc) we may need to generate pssh data and/or pssh box to use in our workflow. This tools helpful to easily provide the base64 pssh data for Widevine and PlayReady.
            Severity: Info
            Found in README.md by markdownlint

            MD013 - Line length

            Tags: line_length

            Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

            This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

            This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

            You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

            Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

            Dollar signs used before commands without showing output
            Open

            ``` bash
            Severity: Info
            Found in README.md by markdownlint

            MD014 - Dollar signs used before commands without showing output

            Tags: code

            Aliases: commands-show-output

            This rule is triggered when there are code blocks showing shell commands to be typed, and the shell commands are preceded by dollar signs ($):

            $ ls
            $ cat foo
            $ less bar

            The dollar signs are unnecessary in the above situation, and should not be included:

            ls
            cat foo
            less bar

            However, an exception is made when there is a need to distinguish between typed commands and command output, as in the following example:

            $ ls
            foo bar
            $ cat foo
            Hello world
            $ cat bar
            baz

            Rationale: it is easier to copy and paste and less noisy if the dollar signs are omitted when they are not needed. See http://www.cirosantilli.com/markdown-styleguide/#dollar-signs-in-shell-code for more information.

            Expected a newline at the end of the file.
            Open

            Severity: Minor
            Found in tslint.json by editorconfig

            Unexpected trailing spaces found.
            Open

            Severity: Minor
            Found in tslint.json by editorconfig

            Expected a newline at the end of the file.
            Open

            }
            Severity: Minor
            Found in tsconfig.json by editorconfig

            TODO found
            Open

                  // TODO: Options to pass predefined contentkey
            Severity: Minor
            Found in src/lib/pssh/playready.ts by fixme
            Severity
            Category
            Status
            Source
            Language