Showing 502 of 502 total issues

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        <label className={this.labelClass()} htmlFor={this.state.uid}>
          {this.props.label}
        </label>
Severity: Minor
Found in src/components/Form/Textarea/Textarea.jsx and 1 other location - About 55 mins to fix
src/components/Form/Dropdown/Dropdown.jsx on lines 383..385

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        <label className={this.labelClass()} htmlFor={this.state.uid}>
          {this.props.label}
        </label>
Severity: Minor
Found in src/components/Form/Dropdown/Dropdown.jsx and 1 other location - About 55 mins to fix
src/components/Form/Textarea/Textarea.jsx on lines 125..127

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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 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 render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      render() {
        const {
          CitizenshipStatus,
          AbroadDocumentation,
          Explanation,
    Severity: Minor
    Found in src/components/Section/Citizenship/Status/Status.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 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 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

    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

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

      addressType() {
        // If address is not applicable ("I don't know"), return ""
        if (!this.props.isEnabled) {
          return ''
        }
    Severity: Minor
    Found in src/components/Form/Location/Address.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 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

      Severity
      Category
      Status
      Source
      Language