hed-standard/hed-javascript

View on GitHub

Showing 41 of 64 total issues

ParsedHedGroup has 41 functions (exceeds 20 allowed). Consider refactoring.
Open

export class ParsedHedGroup extends ParsedHedSubstring {
  static SPECIAL_SHORT_TAGS = new Set(['Definition', 'Def', 'Def-expand', 'Onset', 'Offset', 'Inset'])

  /**
   * The parsed HED tags in the HED tag group.
Severity: Minor
Found in parser/parsedHedGroup.js - About 5 hrs to fix

    Function convertTagToLong has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    export const convertTagToLong = function (schema, hedTag, hedString, offset) {
      const mapping = schema.mapping
    
      if (hedTag.startsWith('/')) {
        hedTag = hedTag.slice(1)
    Severity: Minor
    Found in converter/converter.js - About 4 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 splitHedString has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    export function splitHedString(hedString) {
      const resultPositions = []
      let currentSpacing = 0
      let insideDelimiter = true
      let startPosition = -1
    Severity: Minor
    Found in converter/splitHedString.js - About 3 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 validateUnits has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    export const validateUnits = function (originalTagUnitValue, tagUnitClassUnits, hedSchemaAttributes) {
      const validUnits = getAllUnits(hedSchemaAttributes)
      validUnits.sort((first, second) => {
        return second.length - first.length
      })
    Severity: Minor
    Found in validator/hed2/event/units.js - About 3 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 validateUnits has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      validateUnits(tag) {
        const originalTagUnitValue = tag.originalTagName
        const tagUnitClassUnits = tag.validUnits
        const validUnits = tag.schema.entries.allUnits
        const unitStrings = Array.from(validUnits.keys())
    Severity: Minor
    Found in validator/event/hed3.js - About 2 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

    Hed3Validator has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Hed3Validator extends HedValidator {
      /**
       * The parsed definitions.
       *
       * @type {Map<string, ParsedHedGroup>}
    Severity: Minor
    Found in validator/event/hed3.js - About 2 hrs to fix

      Function checkDefinitionGroupSyntax has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        checkDefinitionGroupSyntax(tagGroup) {
          if (!tagGroup.isDefinitionGroup) {
            return
          }
      
      
      Severity: Minor
      Found in validator/event/hed3.js - About 2 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 findDelimiterIssuesInHedString has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      const findDelimiterIssuesInHedString = function (hedString) {
        const issues = []
        let lastNonEmptyValidCharacter = ''
        let lastNonEmptyValidIndex = 0
        let currentTag = ''
      Severity: Minor
      Found in parser/main.js - 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 checkIfTagUnitClassUnitsAreValid has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        checkIfTagUnitClassUnitsAreValid(tag) {
          if (tag.existsInSchema || !tag.hasUnitClass) {
            return
          }
          const tagUnitClasses = tag.unitClasses
      Severity: Minor
      Found in validator/hed2/event/hed2Validator.js - 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 populateUnitClassUnitsDictionary has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        populateUnitClassUnitsDictionary(unitClassElements) {
          this.unitClasses = {}
          this.unitClassAttributes = {}
          this.unitAttributes = {}
          for (const unitClassKey of unitClassDictionaryKeys) {
      Severity: Minor
      Found in validator/hed2/schema/hed2SchemaParser.js - 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 populateUnitModifierDictionaries has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        populateUnitModifierDictionaries() {
          this.unitModifiers = {}
          const unitModifierElements = this.getElementsByName(unitModifierElement)
          if (unitModifierElements.length === 0) {
            this.hasUnitModifiers = false
      Severity: Minor
      Found in validator/hed2/schema/hed2SchemaParser.js - 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 getValidDerivativeUnits has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      const getValidDerivativeUnits = function (unit, hedSchemaAttributes) {
        const pluralUnits = [unit]
        const isUnitSymbol = hedSchemaAttributes.unitAttributes[unitSymbolType][unit] !== undefined
        if (hedSchemaAttributes.hasUnitModifiers && !isUnitSymbol) {
          pluralUnits.push(pluralize.plural(unit))
      Severity: Minor
      Found in validator/hed2/event/units.js - 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 _checkStandalonePlaceholderStringSyntaxInGroup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        _checkStandalonePlaceholderStringSyntaxInGroup(tags, standalonePlaceholders) {
          let firstStandaloneTag
          for (const tag of tags) {
            const tagString = tag.formattedTag
            const tagPlaceholders = getCharacterCount(tagString, '#')
      Severity: Minor
      Found in validator/event/hed3.js - 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 createParsedTags has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const createParsedTags = function (hedString, hedSchemas, tagSpecs, groupSpecs) {
        const conversionIssues = []
        const syntaxIssues = []
        const ParsedHedTagClass = generationToClass[hedSchemas.generation]
      
      
      Severity: Minor
      Found in parser/splitHedString.js - About 55 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 _spliceSubstring has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        _spliceSubstring(substring) {
          const newData = []
          if (substring instanceof ParsedHedColumnSplice) {
            const substitution = this._spliceTemplate(substring)
            if (substitution === null) {
      Severity: Minor
      Found in parser/columnSplicer.js - About 55 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 convertTagToShort has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export const convertTagToShort = function (schema, hedTag, hedString, offset) {
        const mapping = schema.mapping
      
        if (hedTag.startsWith('/')) {
          hedTag = hedTag.slice(1)
      Severity: Minor
      Found in converter/converter.js - About 55 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 checkIfTagUnitClassUnitsAreValid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        checkIfTagUnitClassUnitsAreValid(tag) {
          if (tag.existsInSchema || !tag.hasUnitClass) {
            return
          }
          const [foundUnit, validUnit, value] = this.validateUnits(tag)
      Severity: Minor
      Found in validator/event/hed3.js - 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 _validateSidecarStrings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        _validateSidecarStrings(sidecar) {
          const issues = []
      
          const categoricalOptions = {
            checkForWarnings: true,
      Severity: Minor
      Found in bids/validator/bidsHedSidecarValidator.js - 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 _checkDefinitionPlaceholderStringSyntaxInGroup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        _checkDefinitionPlaceholderStringSyntaxInGroup(tagGroup) {
          // Count of placeholders within this Definition group.
          let definitionPlaceholders = 0
          const definitionHasPlaceholder = tagGroup.definitionValue === '#'
          const definitionName = tagGroup.definitionName
      Severity: Minor
      Found in validator/event/hed3.js - 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

      Consider simplifying this complex logical expression.
      Open

        if (settingsArg === Object(settingsArg)) {
          settings = {
            checkForWarnings: settingsArg.checkForWarnings ?? false,
            expectValuePlaceholderString: settingsArg.expectValuePlaceholderString ?? false,
            definitionsAllowed: settingsArg.definitionsAllowed ?? 'yes',
      Severity: Major
      Found in validator/event/init.js - About 40 mins to fix
        Severity
        Category
        Status
        Source
        Language