betagouv/service-national-universel

View on GitHub
admin/src/scenes/phase0/view.tsx

Summary

Maintainability
D
1 day
Test Coverage

Function VolontairePhase0View has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

export default function VolontairePhase0View({ young, onChange, globalMode }) {
  const user = useSelector((state: AuthState) => state.Auth.user);
  const cohorts = useSelector((state: CohortState) => state.Cohorts);
  const [currentCorrectionRequestField, setCurrentCorrectionRequestField] = useState("");
  const [requests, setRequests] = useState<NonNullable<YoungDto["correctionRequests"]>>([]);
Severity: Minor
Found in admin/src/scenes/phase0/view.tsx - About 1 day 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 FooterNoRequest has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

function FooterNoRequest({ processing, onProcess, young, footerClass }) {
  const history = useHistory();
  const [confirmModal, setConfirmModal] = useState<ConfirmModalContentData | null>(null);
  const [rejectionReason, setRejectionReason] = useState("");
  const [rejectionMessage, setRejectionMessage] = useState("");
Severity: Minor
Found in admin/src/scenes/phase0/view.tsx - About 4 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 FooterSent has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function FooterSent({ young, requests, reminding, onRemindRequests, footerClass }) {
  const [sentRequestsCount, setSentRequestsCount] = useState(0);

  useEffect(() => {
    setSentRequestsCount(requests.filter((r) => r.status === "SENT" || r.status === "REMINDED").length);
Severity: Minor
Found in admin/src/scenes/phase0/view.tsx - 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

There are no issues that match your filters.

Category
Status