onebeyond/react-form-builder

View on GitHub

Showing 34 of 233 total issues

File countryAndCounties.js has 4585 lines of code (exceeds 250 allowed). Consider refactoring.
Open

export default [
  {
    cn: 'Andorra',
    cs: 'AD',
    regions: [
Severity: Major
Found in src/Questions/County/data/countryAndCounties.js - About 1 wk to fix

    File countryAndRegion.js has 1247 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    export default [
      {
        cn: 'Afghanistan',
        cs: 'AF',
        value: 'afghanistan'
    Severity: Major
    Found in src/Questions/Country/data/countryAndRegion.js - About 3 days to fix

      Function QuestionsMap has 188 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const QuestionsMap = (question) => {
          return {
            box: (
              <div
                sx={{ variant: 'forms.boxContainer' }}
      Severity: Major
      Found in src/builder.js - About 7 hrs to fix

        File builder.js has 384 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /** @jsxRuntime classic */
        /** @jsx jsx */
        import React, { useEffect, useRef, useState } from 'react'
        import { jsx } from 'theme-ui'
        import { useForm, FormProvider } from 'react-hook-form'
        Severity: Minor
        Found in src/builder.js - About 5 hrs to fix

          File fr.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          export default [
            { cn: 'Afghanistan', cs: 'AF', value: 'afghanistan' },
            { cn: 'Afrique du Sud', cs: 'ZA', value: 'south africa' },
            { cn: 'Albanie', cs: 'AL', value: 'albania' },
            { cn: 'Algérie', cs: 'DZ', value: 'algeria' },
          Severity: Minor
          Found in src/Questions/Country/data/fr.js - About 3 hrs to fix

            File de.js has 319 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            export default [
              { cn: 'Afghanistan', cs: 'AF', value: 'afghanistan' },
              { cn: 'Ägypten', cs: 'EG', value: 'egypt' },
              { cn: 'Åland', cs: 'AX', value: 'åland islands' },
              { cn: 'Albanien', cs: 'AL', value: 'albania' },
            Severity: Minor
            Found in src/Questions/Country/data/de.js - About 3 hrs to fix

              File es.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              export default [
                { cn: 'Afganistán', cs: 'AF', value: 'afghanistan' },
                { cn: 'Åland', cs: 'AX', value: 'åland islands' },
                { cn: 'Albania', cs: 'AL', value: 'albania' },
                { cn: 'Alemania', cs: 'DE', value: 'germany' },
              Severity: Minor
              Found in src/Questions/Country/data/es.js - About 3 hrs to fix

                File input.stories.js has 290 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React from 'react'
                import Input from './'
                
                export default {
                  title: 'Question/Input',
                Severity: Minor
                Found in src/Questions/Input/input.stories.js - About 2 hrs to fix

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

                  const QuestionSelectImage = ({ component, form, question, useForm }) => {
                    const {
                      getValues,
                      formState: { errors },
                      register,
                  Severity: Minor
                  Found in src/Questions/SelectImage/index.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 CountriesForm has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const CountriesForm = () => {
                    const [modalText, setModalText] = useState('')
                    const [show, setShow] = useState(false)
                    const [isLoading, setLoading] = useState(false)
                    const [formErrors, setFormErrors] = useState()
                  Severity: Major
                  Found in example/src/forms/Countries/index.jsx - About 2 hrs to fix

                    Function FormBuilder has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const FormBuilder = ({
                      onSubmit: onSubmitForm,
                      currentPath,
                      isLoading,
                      form,
                    Severity: Minor
                    Found in src/builder.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

                    File country.test.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import React from 'react'
                    import {
                      cleanup,
                      getByText,
                      screen,
                    Severity: Minor
                    Found in src/Questions/Country/__tests__/country.test.js - About 2 hrs to fix

                      Function Contact has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const Contact = () => {
                        const [modalText, setModalText] = useState('')
                        const [show, setShow] = useState(false)
                        const [isLoading, setLoading] = useState(false)
                        const [formErrors, setFormErrors] = useState()
                      Severity: Minor
                      Found in example/src/forms/Contact/index.jsx - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                          if (arrows && (arrows.up || arrows.down)) {
                            const { up, down, width, height } = arrows
                        
                            return (
                              <components.DropdownIndicator {...props}>
                        Severity: Critical
                        Found in src/Fields/Select/index.js - About 1 hr to fix

                          Function ConditionalQuestion has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function ConditionalQuestion(question, name, preQuestionType) {
                              return (dependentQuestion, i) => {
                                const nestedQuestion = dependentQuestion && dependentQuestion.question
                          
                                const getConditions = () =>
                          Severity: Minor
                          Found in src/builder.js - About 1 hr to fix

                            Function CountrySubdivisionsForm has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const CountrySubdivisionsForm = () => {
                              const [modalText, setModalText] = useState('')
                              const [show, setShow] = useState(false)
                              const [isLoading, setLoading] = useState(false)
                              const [formErrors, setFormErrors] = useState()
                            Severity: Minor
                            Found in example/src/forms/CountrySubdivisions/index.jsx - About 1 hr to fix

                              Function disableOthers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                              Open

                              const disableOthers = (e) => {
                                Object.entries(e.target.form).forEach(([, v]) => {
                                  if (e.target.checked === true) {
                                    if (v.type === 'checkbox' && v.name === e.target.name && v !== e.target) {
                                      v.checked = false
                              Severity: Minor
                              Found in src/Questions/MultipleCheckboxes/index.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 buildCountryOptions has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const buildCountryOptions = (config, language) => {
                                const priorityOptions = config?.priorityOptions || []
                                const whitelist = config?.whitelist || []
                                const blacklist = config?.blacklist || []
                                const flag = config?.flag || false
                              Severity: Minor
                              Found in src/Questions/CountryV2/index.js - About 1 hr to fix

                                Function QuestionAutocomplete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const QuestionAutocomplete = ({ question, useForm }) => {
                                  const {
                                    formState: { errors },
                                    defaultValue,
                                    control,
                                Severity: Minor
                                Found in src/Questions/Autocomplete/index.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 buildCountrySubdivisonOptions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const buildCountrySubdivisonOptions = (config, selectedCountryCode) => {
                                  const priorityOptions = config.priorityOptions?.[selectedCountryCode] || []
                                  const whitelist = config.whitelist?.[selectedCountryCode] || []
                                  const blacklist = config.blacklist?.[selectedCountryCode] || []
                                  const valueType = config.valueType
                                Severity: Minor
                                Found in src/Questions/CountrySubdivision/buildCountrySubdivisonOptions.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language