Showing 923 of 941 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
function validateSchool(data) {
if (data.isAbroad) {
if (!data?.school?.fullName) return false;
if (!data?.school?.country) return false;
return true;
- 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 157.
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={`relative border-[1px] border-gray-300 ${dragActive ? "border-solid bg-gray-100" : "border-dashed"} flex flex-col items-center p-4 ${className}`}
onDragEnter={dragIn}>
<AddImage className="txt-gray-400 mb-3" />
- 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 306.
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={`relative border-[1px] border-gray-300 ${dragActive ? "border-solid bg-gray-100" : "border-dashed"} flex flex-col items-center p-4 ${className}`}
onDragEnter={dragIn}>
<AddImage className="txt-gray-400 mb-3" />
- 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 306.
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 Phase1Header
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const Phase1Header = ({ setLoading, young = null, editing = false, setEditing, loading = false, setValues, setYoung, user }) => {
const [modal, setModal] = useState({ isOpen: false, onConfirm: null });
const [modalDispense, setModalDispense] = useState({ isOpen: false });
const canUserDownloadConvocation = () => {
- 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
Avoid deeply nested control flow statements. Open
if (idx < legends.length) {
newLegends.push(legends[idx]);
} else {
newLegends.push(null);
}
Function ChooseRole
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const ChooseRole = ({ value, onChange, validate }) => {
const { user } = useSelector((state) => state.Auth);
return (
<Field as="select" validate={validate} className="form-control" placeholder="Rôle" name="role" value={value} onChange={onChange}>
- 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 FileUpload
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const FileUpload = ({ className, files = [], addFiles, deleteFile, filesAccepted = ["jpeg", "png", "pdf"], disabled = false }) => {
const inputRef = useRef(null);
const accept = Object.keys(FILES_ACCEPTED).reduce((previous, current) => {
if (filesAccepted.includes(current)) {
return `${previous}${previous ? ", " : ""}${FILES_ACCEPTED[current].join(", ")}`;
- 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 getPages
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
export function getPages(lastDisplayItem, firstDisplayPage, lastDisplayPage, itemsCountTotal, lastPage, size) {
Function Phase2MilitaryPreparation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export default function Phase2MilitaryPreparation({ young }) {
const [militaryOpen, setMilitaryOpen] = useState(false);
const [modalFiles, setModalFiles] = useState({ isOpen: false, title: "", nameFiles: "", initialValues: [] });
return (
<div className="mx-8 mt-7 rounded-lg bg-white">
- 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 putLocation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const putLocation = async (city, zip) => {
try {
if (!city && !zip) return;
// try with municipality = city + zip
const resMunicipality = await apiAdress(city + " " + zip, { type: "municipality" });
- 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 PDRpropose
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export default function PDRpropose({ young, center, modalAffectations, setModalAffectation }) {
const [dataPdr, setDataPdr] = useState([]);
const [loadingPdr, setLoadingPdr] = useState(false);
useEffect(() => {
- 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
Avoid deeply nested control flow statements. Open
if (idx < legends.length) {
newLegends.push(legends[idx]);
} else {
newLegends.push(null);
}
Function FilterComponent
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const FilterComponent = ({ filter, selectedFilters, setSelectedFilters, maxItems = 3 }) => {
const selectedFilterValues = selectedFilters[filter.id]?.length ? selectedFilters[filter.id] : [];
const [visible, setVisible] = React.useState(false);
return (
- 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 MissionsProposedPlaces
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export default function MissionsProposedPlaces({ filters, missionFilters, className = "" }) {
const [graph, setGraph] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
- 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 Line
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const Line = ({ modification, tagsOptions, user }) => {
const history = useHistory();
const [open, setOpen] = React.useState(false);
const refContainer = React.useRef(null);
const refChildren = React.useRef(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 ListPresence
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export default function ListPresence() {
const user = useSelector((state) => state.Auth.user);
const history = useHistory();
const [data, setData] = React.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 Hit
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const Hit = ({ hit, onClick, onChangeApplication, selected, onSelect, currentTab, opened, history }) => {
const numberOfFiles = hit?.contractAvenantFiles.length + hit?.justificatifsFiles.length + hit?.feedBackExperienceFiles.length + hit?.othersFiles.length;
const bgColor = selected ? "bg-blue-500" : opened ? "bg-blue-100" : "";
const mainTextColor = selected ? "text-white" : "text-[#242526]";
return (
- 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 Department
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const Department = ({ department, loadingQuery, data, youngInDepartment, placesCenterByDepartment, onCreate, onDelete, regionAccueil, selectAll, user }) => {
const [open, setOpen] = React.useState(false);
const [assignDepartment, setAssignDepartment] = React.useState([]);
const canEdit = (user.role === ROLES.REFERENT_REGION && user.region === department2region[department]) || user.role === ROLES.ADMIN;
- 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 checkTime
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function checkTime(time1, time2) {
var time1Split = time1.split(":");
var time2Split = time2.split(":");
// Check if the hours are equal
- 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 Index
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export default function Index({ ...props }) {
const [mission, setMission] = useState(null);
useDocumentTitle(mission ? `${mission.name}` : "Missions");
const [tutor, setTutor] = useState(null);
const [structure, setStructure] = 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"