betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

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

export default function BoxCentres({ summary, className, loading, isNational, isDepartmental, user }: BoxProps & { isNational?: boolean; isDepartmental?: boolean; user: User }) {
  return (
    <Box className={`overflow-hidden ${className} w-1/3`}>
      <FrenchMap className="absolute right-[-40px] top-[30px] z-[0]" />
      <MiniTitle className="mb-[10px] flex items-center">

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

export default function Index(props) {
  const cohort = new URLSearchParams(props.location.search).get("cohort");
  const addLigne = new URLSearchParams(props.location.search).get("add");
  const [steps, setSteps] = useState<ImportStep[]>([
    { id: "étape 1", name: "Le modèle vierge", status: "current" },
Severity: Minor
Found in admin/src/scenes/plan-transport/ligne-bus/import/index.tsx - 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 Alerte has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export default function Alerte() {
  const { user } = useSelector((state: AuthState) => state.Auth);
  const [isNew, setIsNew] = useState(false);

  const { data: messages, refetch } = useQuery<AlerteMessageDto[]>({
Severity: Minor
Found in admin/src/scenes/alerte/index.tsx - 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 Field has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export default function Field({ onChange, value, label, disabled = false, error, readOnly = false, copy, className = "", tooltips = null }: Props) {
  const [copied, setCopied] = React.useState(false);

  React.useEffect(() => {
    if (copied) {
Severity: Minor
Found in admin/src/scenes/centersV2/components/Field.tsx - 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 SideBar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const SideBar = ({ sessionsList }) => {
  const dispatch = useDispatch();

  //Location
  const location = useLocation();
Severity: Minor
Found in admin/src/components/drawer/SideBar.tsx - 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 <MobilePresentation step={step} />;
Severity: Major
Found in app/src/scenes/representants-legaux/index.jsx - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        if (step === STEPS.IMAGE_RIGHTS_DONE_PARENT2) return <MobileImageRightsDone step={step} parentId={2} />;
    Severity: Major
    Found in app/src/scenes/representants-legaux/index.jsx - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return res.status(200).send({ ok: true, data: mail });
      Severity: Major
      Found in api/src/controllers/application.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return res.status(404).send({ ok: false, code: ERRORS.NOT_FOUND });
        Severity: Major
        Found in api/src/controllers/application.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return [ROLES.ADMIN, ROLES.REFERENT_REGION, ROLES.REFERENT_DEPARTMENT, ROLES.TRANSPORTER, ROLES.ADMINISTRATEUR_CLE, ROLES.REFERENT_CLASSE].includes(actor.role);
          Severity: Major
          Found in packages/lib/src/roles.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return false;
            Severity: Major
            Found in packages/lib/src/roles.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return [ROLES.ADMINISTRATEUR_CLE, ROLES.REFERENT_CLASSE].includes(actor.role);
              Severity: Major
              Found in packages/lib/src/roles.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return [ROLES.ADMIN, ROLES.REFERENT_REGION, ROLES.REFERENT_DEPARTMENT, ROLES.ADMINISTRATEUR_CLE, ROLES.REFERENT_CLASSE, ROLES.TRANSPORTER].includes(actor.role);
                Severity: Major
                Found in packages/lib/src/roles.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return [ROLES.ADMIN, ROLES.REFERENT_REGION, ROLES.REFERENT_DEPARTMENT].includes(actor.role);
                  Severity: Major
                  Found in packages/lib/src/roles.ts - About 30 mins to fix

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

                      React.useEffect(() => {
                        const handleClickOutside = (event) => {
                          if (refContainer.current && refContainer.current.contains(event.target)) {
                            setOpen((open) => !open);
                          } else if (refSelect.current && !refSelect.current.contains(event.target)) {
                    admin/src/scenes/edit-transport/list/components/PointDeRassemblement.jsx on lines 17..29

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

                    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

                      React.useEffect(() => {
                        const handleClickOutside = (event) => {
                          if (refContainer.current && refContainer.current.contains(event.target)) {
                            setOpen((open) => !open);
                          } else if (refSelect.current && !refSelect.current.contains(event.target)) {
                    admin/src/scenes/plan-transport/ligne-bus/View/components/PointDeRassemblement.jsx on lines 47..59

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

                    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

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

                    export const buildQuery = async (route, selectedFilters, page = 0, filterArray, sort, size = 10) => {
                      try {
                        const resAlternative = await api.post(route, {
                          page,
                          filters: Object.entries(selectedFilters).reduce((e, [key, value]) => {
                    Severity: Minor
                    Found in admin/src/components/filters-system-v2/components/filters/utils.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 ApplicationList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export default function ApplicationList({ young, onChangeApplication }) {
                      const [applications, setApplications] = useState(null);
                      const optionsType = ["contractAvenantFiles", "justificatifsFiles", "feedBackExperienceFiles", "othersFiles"];
                    
                      useEffect(() => {
                    Severity: Minor
                    Found in admin/src/scenes/volontaires/view/phase2bis/applicationList2.jsx - 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 Toolbox has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export default function Toolbox({ young }) {
                      const cohortList = useSelector((state) => state.Cohorts);
                      const history = useHistory();
                    
                      const cohort = cohortList.find((c) => c.name === young.cohort);
                    Severity: Minor
                    Found in admin/src/scenes/volontaires/components/Toolbox.jsx - 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 Presences has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export default function Presences({ presence, JDM, depart, departTotal, departMotif, filter, role, sessionId, centerId, cohortHeadCenter = null }) {
                      const departPercentage = departTotal ? depart?.true / departTotal : 0;
                      const base = role === ROLES.HEAD_CENTER ? `/centre/${centerId}/${sessionId}/tableau-de-pointage` : "/volontaire";
                      return (
                        <div className="flex flex-col gap-10 rounded-lg bg-white px-6 pt-8 pb-16 shadow-[0_8px_16px_-3px_rgba(0,0,0,0.05)]">
                    Severity: Minor
                    Found in admin/src/scenes/dashboardV2/components/sejour/Presences.jsx - 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