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
- Read upRead up
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
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
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
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"?>']
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')
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
- Read upRead up
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')
- Read upRead up
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"?>']
- Read upRead up
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)
- Read upRead up
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"