betagouv/service-national-universel

View on GitHub

Showing 923 of 941 total issues

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

module.exports = (data) => {
  return (req, res, next) => {
    try {
      if (typeof data.validate !== "function") data = Joi.object(data);
      const { error, value } = data.validate(req.body);
Severity: Minor
Found in analytics/src/middlewares/validation.middleware.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 Details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const Details = ({ title, value, copy }) => {
  if (!value) return <div />;
  const [copied, setCopied] = React.useState(false);
  if (typeof value === "function") value = value();
  React.useEffect(() => {
Severity: Minor
Found in admin/src/components/Panel.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 MultiSelect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function MultiSelect({ options, selected, setSelected, label, readOnly = false, icon, error }) {
  const border = (open) => {
    if (readOnly) return "border-gray-200";
    if (error) return "border-red-500";
    if (open) return "border-blue-500";
Severity: Minor
Found in admin/src/components/forms/MultiSelect.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 InputNumber has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function InputNumber({ register, name, label, disabled = false, error = "", readOnly = false, placeholder = "", validation = {} }) {
  return (
    <div
      className={`flex min-h-[54px] w-full flex-col justify-center rounded-lg border-[1px] bg-white py-2 px-2.5 ${disabled ? "border-gray-200" : "border-gray-300"} ${
        error ? "border-red-500" : ""
Severity: Minor
Found in admin/src/components/ui/forms/InputNumberHookForm.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 Select has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function Select({ options, selected, setSelected, label, readOnly = false, icon, error }) {
  const border = (open) => {
    if (readOnly) return "border-gray-200";
    if (error) return "border-red-500";
    if (open) return "border-blue-500";
Severity: Minor
Found in admin/src/components/forms/Select.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 Field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

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

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

export default function VolontaireList() {
  const user = useSelector((state) => state.Auth.user);
  const history = useHistory();
  if (user?.role === ROLES.ADMINISTRATEUR_CLE) return history.push("/mes-eleves");

Severity: Minor
Found in admin/src/scenes/volontaires/list.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 HorizontalBar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function HorizontalBar({ title, values, labels, showTooltips = false, legendUrls, goal, className = "", onLegendClicked = () => {} }) {
  const [bars, setBars] = useState([]);
  const [total, setTotal] = useState(0);
  const [totalPercent, setTotalPercent] = useState("-");
  const [x100, setX100] = useState(null);
Severity: Minor
Found in admin/src/scenes/dashboardV2/components/graphs/HorizontalBar.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 SignupInvite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function SignupInvite() {
  const [invitation, setInvitation] = useState("");
  const [newuser, setNewUser] = useState(null);

  const urlParams = new URLSearchParams(window.location.search);
Severity: Minor
Found in admin/src/scenes/auth/signupInvite.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 currentFilterAsUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const currentFilterAsUrl = (filters) => {
  let selectedFilters = {};
  Object.keys(filters)?.forEach((key) => {
    if (filters[key]?.length > 0) selectedFilters[key] = filters[key];
  });
Severity: Minor
Found in admin/src/scenes/dashboardV2/components/FilterDashBoard.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 translateHistory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function translateHistory(path, value) {
  if (path.includes("statusPhase1")) {
    return translatePhase1(value);
  } else if (path.includes("statusPhase2")) {
    return translatePhase2(value);
Severity: Minor
Found in admin/src/utils/index.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 InputText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function InputText({ register, name, label, disabled = false, error = "", readOnly = false, placeholder = "", validation = {} }) {
  return (
    <div
      className={`flex min-h-[54px] w-full flex-col justify-center rounded-lg border-[1px] bg-white py-2 px-2.5 ${disabled ? "border-gray-200" : "border-gray-300"} ${
        error ? "border-red-500" : ""
Severity: Minor
Found in admin/src/components/ui/forms/InputTextHookForm.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 InputText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function InputText({ onChange, value, label, disabled = false, error, readOnly = false, placeholder }) {
  return (
    <div
      className={`flex min-h-[54px] w-full flex-col justify-center rounded-lg border-[1px] bg-white py-2 px-2.5 ${disabled ? "border-gray-200" : "border-gray-300"} ${
        error ? "border-red-500" : ""
Severity: Minor
Found in admin/src/components/ui/forms/InputText.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 Select has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function Select({ options, value, onChange, label, readOnly = false, icon, error }) {
  const border = (open) => {
    if (readOnly) return "border-gray-200";
    if (error) return "border-red-500";
    if (open) return "border-blue-500";
Severity: Minor
Found in admin/src/components/forms/SelectHookForm.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 TotalInscription has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function TotalInscription({ totalInscriptions, goal }) {
  const dataInscription = totalInscriptions?.reduce((acc, curr) => {
    if (!acc.length) {
      acc.push(curr.doc_count);
    } else {

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

export const formatPhoneE164 = (phone, phoneZone) => {
  if (!phone) {
    return;
  }
  if (typeof phone !== "string") {
Severity: Minor
Found in admin/src/utils/formatPhoneE164.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 PanelView has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function PanelView({ onChange, value, application }) {
  const [young, setYoung] = useState(null);

  useEffect(() => {
    (async () => {
Severity: Minor
Found in admin/src/scenes/volontaires-responsible/panel.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 DeletedVolontairePanel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function DeletedVolontairePanel({ onChange, value }) {
  const [young, setYoung] = useState(null);

  useEffect(() => {
    (async () => {
Severity: Minor
Found in admin/src/scenes/volontaires/deletedPanel.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 ExportComponent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function ExportComponent({
  handleClick,
  title,
  exportTitle,
  route,

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

export default function List() {
  const user = useSelector((state) => state.Auth.user);
  const [structures, setStructures] = useState();
  const [responsable, setResponsable] = useState(null);
  const [NewUserOpen, setNewUserOpen] = useState(false);
Severity: Minor
Found in admin/src/scenes/team/list.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