hed-standard/hed-javascript

View on GitHub

Showing 41 of 64 total issues

Function parseTags has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  parseTags() {
    const [tags, tagElements] = this.getAllTags()
    const lowercaseTags = tags.map(lc)
    this.tags = new Set(lowercaseTags)
    const [booleanAttributeDefinitions, valueAttributeDefinitions] = this._parseAttributeElements(
Severity: Minor
Found in validator/schema/hed3.js - 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 checkIfTagIsValid has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  checkIfTagIsValid(tag, previousTag) {
    if (tag.existsInSchema || tag.takesValue) {
      return
    }

Severity: Minor
Found in validator/event/hed3.js - 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 buildMappingObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const buildMappingObject = function (entries) {
  /**
   * @type {Map<string, TagEntry>}
   */
  const shortTagData = new Map()
Severity: Minor
Found in converter/schema.js - 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 constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  constructor(name, booleanAttributes, valueAttributes, unitModifiers) {
    super(name, booleanAttributes, valueAttributes)

    this._derivativeUnits = [name]
    if (!this.isSIUnit) {
Severity: Minor
Found in validator/schema/types.js - 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 populateTagDictionaries has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  populateTagDictionaries() {
    this.tagAttributes = {}
    for (const dictionaryKey of tagDictionaryKeys) {
      const [tags, tagElements] = this.getTagsByAttribute(dictionaryKey)
      if (dictionaryKey === extensionAllowedAttribute) {
Severity: Minor
Found in validator/hed2/schema/hed2SchemaParser.js - 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 parseProperties has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  parseProperties() {
    const propertyDefinitions = this.getElementsByName('propertyDefinition')
    this.properties = new Map()
    for (const definition of propertyDefinitions) {
      const propertyName = this.getElementTagName(definition)
Severity: Minor
Found in validator/schema/hed3.js - 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 splitLibraryAndVersion has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function splitLibraryAndVersion(schemaVersion, originalVersion) {
  const versionSplit = schemaVersion.split('_')
  let library = ''
  let version
  if (versionSplit.length > 2) {
Severity: Minor
Found in bids/schema.js - 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

Avoid too many return statements within this function.
Open

      return this._spliceValueTemplate(columnTemplate)
Severity: Major
Found in parser/columnSplicer.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return replacementString.parseTree
    Severity: Major
    Found in parser/columnSplicer.js - About 30 mins to fix

      Function initiallyValidateHedString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      const initiallyValidateHedString = function (hedString, hedSchemas, options, definitions = null) {
        const doSemanticValidation = hedSchemas instanceof Schemas
        if (!doSemanticValidation) {
          hedSchemas = new Schemas(null)
        }
      Severity: Minor
      Found in validator/event/init.js - 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

      Function _convertTag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        _convertTag(hedString, hedSchemas, schemaName) {
          const hed3ValidCharacters = /^[^{}[\]()~,\0\t]+$/
          if (!hed3ValidCharacters.test(this.originalTag)) {
            throw new Error('The parser failed to properly remove an illegal or special character.')
          }
      Severity: Minor
      Found in parser/parsedHedTag.js - 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

      Function validateSidecarCurlyBraces has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        static validateSidecarCurlyBraces(sidecar) {
          const issues = []
          const references = sidecar.columnSpliceMapping
      
          for (const [key, referredKeys] of references) {
      Severity: Minor
      Found in bids/validator/bidsHedSidecarValidator.js - 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

      Function validateHedDataset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const validateHedDataset = function (hedStrings, hedSchemas, ...args) {
        let settings
        if (args[0] === Object(args[0])) {
          settings = {
            checkForWarnings: args[0].checkForWarnings ?? false,
      Severity: Minor
      Found in validator/dataset.js - 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

      Function checkIfTagIsValid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        checkIfTagIsValid(tag, previousTag) {
          if (tag.existsInSchema || tag.takesValue) {
            return
          }
          // Whether this tag has an ancestor with the 'extensionAllowed' attribute.
      Severity: Minor
      Found in validator/event/validator.js - 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

      Function checkTemporalSyntax has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        checkTemporalSyntax(tagGroup) {
          if (!tagGroup.isTemporalGroup) {
            return
          }
          const definitionName = this._getTemporalDefinitionName(tagGroup)
      Severity: Minor
      Found in validator/event/hed3.js - 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

      Function checkForInvalidTopLevelTagGroupTags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        checkForInvalidTopLevelTagGroupTags() {
          for (const tag of this.parsedString.tags) {
            if (!tag.hasAttribute(topLevelTagGroupType) && !tag.parentHasAttribute(topLevelTagGroupType)) {
              continue
            }
      Severity: Minor
      Found in validator/event/hed3.js - 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

      Function validateHedDatasetWithContext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const validateHedDatasetWithContext = function (hedStrings, contextHedStrings, hedSchemas, ...args) {
        let settings
        if (args[0] === Object(args[0])) {
          settings = {
            checkForWarnings: args[0].checkForWarnings ?? false,
      Severity: Minor
      Found in validator/dataset.js - 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

      Function isDescendantOf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        isDescendantOf(parent) {
          if (parent instanceof ParsedHedTag) {
            if (this.schema !== parent.schema) {
              return false
            }
      Severity: Minor
      Found in parser/parsedHedTag.js - 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

      Function generateMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        generateMessage() {
          // Convert all parameters except the substring bounds (an integer array) to their string forms.
          this.parameters = mapValues(this.parameters, (value, key) => (key === 'bounds' ? value : String(value)))
      
          const bounds = this.parameters.bounds ?? []
      Severity: Minor
      Found in common/issues/issues.js - 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

      Function _parseHedColumn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        _parseHedColumn() {
          const hedColumn = this.parsedTsv.get('HED')
          if (hedColumn === undefined) {
            this.hedColumnHedStrings = []
          } else {
      Severity: Minor
      Found in bids/types/tsv.js - 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