Showing 923 of 941 total issues
Function GroupAffectationSummary
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function GroupAffectationSummary({ group, className = "", onChange, onChangeStep, isUserAuthorizedToCreateGroup }) {
const { user } = useSelector((state) => state.Auth);
const [loading, setLoading] = useState(true);
const [detail, setDetail] = useState(null);
const [error, setError] = useState(null);
- Read upRead up
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 exportLigneBusJeune
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export async function exportLigneBusJeune(cohort, ligne, travel, team) {
try {
const youngs = await API.post(`/elasticsearch/young/in-bus/${String(ligne._id)}/export`, {
filters: {},
exportFields: "*",
- Read upRead up
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 CorrectedRequest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function CorrectedRequest({ young, correctionRequest, className, reasons }) {
const [correctionView, setCorrectionView] = useState(false);
function toggleCorrectionView() {
setCorrectionView(!correctionView);
- Read upRead up
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 AccountPasswordPage
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const AccountPasswordPage = () => {
const dispatch = useDispatch();
const [formValues, setFormValues] = useState(INITIAL_FORM_VALUES);
- Read upRead up
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 ModalPointagePresenceJDM
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function ModalPointagePresenceJDM({ isOpen, onSubmit, onCancel, values }) {
const [isLoading, setIsLoading] = React.useState(false);
const [viewList, setViewList] = React.useState(false);
const isPlural = values?.length > 1;
- Read upRead up
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 InscriptionClosed
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function InscriptionClosed({ young, isCLE }) {
const statusWording = (young, isCLE) => {
if (isCLE) {
if ([YOUNG_STATUS.REINSCRIPTION, YOUNG_STATUS.IN_PROGRESS].includes(young.status)) {
return "Votre inscription n'a pas été complétée à temps.";
- Read upRead up
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 MissionList
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function MissionList({ publisherName }) {
const young = useSelector((state) => state.Auth.young);
const history = useHistory();
const params = new URLSearchParams(window.location.search);
- Read upRead up
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 View
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function View({ young, onSave, saving, onToggleDomain, hasDomainSelected, onChange, mobile, errors }) {
return (
<div className="pb-24">
{Object.values(errors).length ? <div className="text-center mt-6 text-sm text-[#F71701]">Il y a des erreurs ou des données manquantes dans le formulaire.</div> : null}
<Section>
- Read upRead up
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 StepMedicalField
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function StepMedicalField({ data }) {
const index = 4;
const young = useSelector((state) => state.Auth.young);
const isEnabled = isStepDone(STEPS.CONVOCATION, young);
const isDone = isStepDone(STEPS.MEDICAL_FILE, young);
- Read upRead up
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 mission
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function mission({ mission: missionProp, location }) {
const mission = missionProp._source;
const tags = [];
mission.city && tags.push(mission.city + (mission.zip ? ` - ${mission.zip}` : ""));
mission.domains.forEach((d) => tags.push(translate(d)));
- Read upRead up
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 handler
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
exports.handler = async () => {
try {
const processContacts = async (Model, type) => {
const cursor = Model.find({ updatedAt: { $gte: new Date(new Date() - 24 * 60 * 60 * 1000) } }).cursor();
let contactsWithAttributes = [];
- Read upRead up
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 ModalPJ
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function ModalPJ({ isOpen, onCancel, onSave, onSend, name, young, application, optionsType, typeChose }) {
const [type, setType] = useState();
const [stepOne, setStepOne] = useState();
const [disabledSave, setDisabledSave] = useState(true);
const [newFilesList, setNewFilesList] = useState([]);
- Read upRead up
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 checkStatusContract
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const checkStatusContract = (contract) => {
if (!contract.invitationSent || contract.invitationSent === "false") return "DRAFT";
// To find if everybody has validated we count actual tokens and number of validated. It should be improved later.
const tokenKeys = ["projectManagerToken", "structureManagerToken"];
const validateKeys = ["projectManagerStatus", "structureManagerStatus"];
- Read upRead up
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 YoungRowImageRight
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function YoungRowImageRight({ young, selectedYoungs, onYoungSelected, onChange }: Props) {
const history = useHistory();
const [showModale, setShowModale] = useState(false);
const [authorized, setAuthorized] = useState(false);
- Read upRead up
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 YoungRowConsent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export default function YoungRowConsent({ young, selectedYoungs, onYoungSelected, onChange }: Props) {
const history = useHistory();
const [showModale, setShowModale] = useState(false);
const [authorized, setAuthorized] = useState(false);
- Read upRead up
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 ListBus
has 205 lines of code (exceeds 200 allowed). Consider refactoring. Open
export default function ListBus(props) {
const id = props.match && props.match.params && props.match.params.id;
if (!id) return <div />;
const [bus, setBus] = React.useState();
const [loading, setLoading] = React.useState(true);
Function transformVolontairesCLE
has 205 lines of code (exceeds 200 allowed). Consider refactoring. Open
export async function transformVolontairesCLE(data, values) {
const all = data;
interface Center {
_id?: string;
Similar blocks of code found in 2 locations. Consider refactoring. Open
return (
<div className={`items-center justify-center ${className}`}>
<div className="flex items-center rounded-lg bg-gray-50 p-9">
{hasTimeSchedule ? <UploadedFileIcon /> : <EmptyFileIcon />}
<div className="grow-1 mx-7">
- Read upRead up
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 314.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
return (
<div className={`items-center justify-center ${className}`}>
<div className="flex items-center rounded-lg bg-gray-50 p-9">
{hasPedagoProject ? <UploadedFileIcon /> : <EmptyFileIcon />}
<div className="grow-1 mx-7">
- Read upRead up
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 314.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function transformVolontaires
has 204 lines of code (exceeds 200 allowed). Consider refactoring. Open
export async function transformVolontaires(data, values) {
let all = data;
return all.map((data) => {
let center = {};