18F/e-QIP-prototype

View on GitHub

Showing 132 of 502 total issues

Consider simplifying this complex logical expression.
Open

    if (o.BenefitFrequency) {
      switch (o.BenefitFrequency.value) {
        case 'OneTime':
          b = o.OneTimeBenefit || {}
          benefit.Country = (b.Country || {}).value

    Consider simplifying this complex logical expression.
    Open

      if (options.requireRelationshipRelativesForeignBornDoc) {
        return !!((
          isCitizen(attributes)
          && !wasBornInUS(attributes)
          && !isLiving(attributes)
    Severity: Major
    Found in src/models/relative.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

        if (value === null
          || value === undefined
          || value === ''
          || (Array.isArray(value) && value.length === 0)
          || (value.constructor === Object && Object.keys(value).length === 0)) {
      Severity: Major
      Found in src/models/validators/requireEmpty.js - About 1 hr to fix

        Function onBranchClick has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          onBranchClick(item, index, values) {
            const {
              items, valueKey, removable, onUpdate,
            } = this.props
        
        
        Severity: Minor
        Found in src/components/Form/BranchCollection/BranchCollection.jsx - 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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          render() {
            const klass = `${
              this.props.hideMonth && this.props.hideDay ? '' : 'datecontrol'
            } ${
              this.state.error && !this.props.overrideError ? 'usa-input-error' : ''
        Severity: Minor
        Found in src/components/Form/DateControl/DateControl.jsx - 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 containsRequiredItems has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        const containsRequiredItems = (value, options = {}) => {
          if (validate.isEmpty(value)) return null // Don't validate if there is no value
        
          const { items } = value
          if (!items || (items && items.length < 1)) return MISSING_ITEMS
        Severity: Minor
        Found in src/models/validators/containsRequiredItems.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 login has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export function* login({ username, password }) {
          try {
            const response = yield call(api.login, username, password)
        
            yield put(handleLoginSuccess(response))
        Severity: Minor
        Found in src/sagas/api.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 DiplomaSummary has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        const DiplomaSummary = (item) => {
          if (((item.Diplomas || {}).items || []).length === 0) {
            return []
          }
        
        
        Severity: Minor
        Found in src/components/Section/History/summaries.jsx - 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 Summary has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export const Summary = (props = {}) => {
          props = {
            type: 'Item',
            index: -1,
            left: '',
        Severity: Minor
        Found in src/components/Summary/Summary.jsx - 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 getFormSections has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          (formType, disciplinaryProceduresHidden, selectiveServiceHidden, existingConditionsHidden) => {
            // Make a copy b/c we are going to mutate this
            // Might want to add & use update here to make this easier
            let formTypeSections = formTypeConfig[formType]
        
        
        Severity: Minor
        Found in src/selectors/navigation.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 reduceSubsections has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export const reduceSubsections = (sections, parentPath, breadcrumbs = [], parentStore) => (
          sections.reduce((accumulator, section) => {
            if (section.subsections && section.subsections.length) {
              const builtPath = parentPath
                ? `${parentPath}/${section.path}`
        Severity: Minor
        Found in src/config/formTypes.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 validMiddle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          validMiddle() {
        
            if (this.hideMiddleName) {
              return true
            }
        Severity: Minor
        Found in src/validators/name.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

        Method Benefit.Unmarshal has 14 return statements (exceeds 10 allowed).
        Open

        func (entity *Benefit) Unmarshal(raw []byte) error {
            err := json.Unmarshal(raw, entity)
            if err != nil {
                return err
            }
        Severity: Major
        Found in api/benefit.go - About 50 mins to fix

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

            componentDidMount() {
              if (this.props.children) {
                let arr = []
                for (let child of this.props.children) {
                  if (child && child.type === 'option') {
          Severity: Minor
          Found in src/components/Form/Dropdown/Dropdown.jsx - 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 func has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              func: (value, props) => {
                if (props.required) {
                  if (props.allowNotApplicable && props.noNumber) {
                    return true
                  }
          Severity: Minor
          Found in src/components/Form/Telephone/Telephone.jsx - 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

          Avoid deeply nested control flow statements.
          Open

                              if saveAgainErr != nil {
                                  // this time, nothing will save you.
                                  service.Log.WarnError(api.EntitySaveError, saveAgainErr, api.LogFields{})
                                  RespondWithStructuredError(w, api.EntitySaveError, http.StatusInternalServerError)
                                  return
          Severity: Major
          Found in api/http/save.go - About 45 mins to fix

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

              render() {
                const {
                  Education, formType, inReview, errors, data,
                } = this.props
            
            
            Severity: Minor
            Found in src/components/Section/History/Education/EducationWrapper.jsx - 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 validateFields has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
            Open

            func validateFields(entity *Location, props ...string) ErrorStack {
                var stack ErrorStack
            
                for _, prop := range props {
                    switch strings.ToLower(prop) {
            Severity: Minor
            Found in api/location.go - 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 renderMessage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            const renderMessage = (id, messageString, titleString) => {
              const noteId = `${id}.note`
              let note = i18n.m(noteId)
              if (
                Object.prototype.toString.call(note) === '[object String]'
            Severity: Minor
            Found in src/components/Form/Field/Field.jsx - 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 validPhoneNumber has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const validPhoneNumber = (phone, opts = { numberType: false }) => {
              if (!phone) {
                return false
              }
              if (phone.noNumber) {
            Severity: Minor
            Found in src/validators/helpers.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

            Severity
            Category
            Status
            Source
            Language