Showing 923 of 941 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
export function Button({ children, className = "", onClick = () => {}, spinner = false, icon, href, target, rel }) {
if (href) {
return (
<a
className={`inline-flex cursor-pointer items-center justify-center whitespace-nowrap rounded-[6px] border-[1px] border-solid border-[transparent] bg-[#FFFFFF] px-3 py-2 text-[#1F2937] hover:border-[#D1D5DB] ${className}`}
- 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 319.
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 Field
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function Field({
name,
label = "",
value,
className = "",
- 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 formatHistory
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export function formatHistory(data, role) {
if (!data) return [];
// Flatten history: each value inside each op is a separate event
let history = [];
for (const e of data) {
- 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 ModalConfirmWithMessage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function ModalConfirmWithMessage({
isOpen,
topTitle = "alerte",
title,
message,
- 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 DatePicker
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function DatePicker({ value, onChange, disabled, fromYear, toYear, mode = "single" }) {
const defaultMonth =
mode === "single"
? value
? dayjs(value).toUtcLocally().toDate()
- 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 ModalChangeStatus
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function ModalChangeStatus({ isOpen, onCancel, status, equivalenceId, young }) {
const [isLoading, setIsLoading] = React.useState(false);
const [message, setMessage] = React.useState();
const history = useHistory();
- 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 Association
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function Association({ hit, missionsInfo }) {
const tabs = ["Informations", "Contacts", "Missions"];
const [show, setShow] = useState(false);
const [tab, setTab] = useState("Informations");
const association = hit;
- 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 12 (exceeds 5 allowed). Consider refactoring. Open
export default function Index({ user }) {
const cohorts = useSelector((state) => state.Cohorts);
const [inscriptionGoals, setInscriptionGoals] = useState();
const [volontairesData, setVolontairesData] = useState();
const [inAndOutCohort, setInAndOutCohort] = 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 GroupModificationEnhanced
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function GroupModificationEnhanced({ group, className = "", onChangeStep }) {
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 exportLigneBus
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export async function exportLigneBus(cohort) {
try {
const { ok, data: ligneBus } = await API.post(`/elasticsearch/lignebus/export?needYoungInfo=true&needCohesionCenterInfo=true&needMeetingPointsInfo=true`, {
filters: { cohort: [cohort] },
});
- 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 Equivalence
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function Equivalence() {
const { young } = useAuth();
const { id } = useParams();
const { data, isError, isPending } = useQuery({ queryKey: ["equivalence", id], queryFn: () => fetchEquivalence(young._id, id) });
- 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 StepConvocation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function StepConvocation({ data: { center, meetingPoint, departureDate, returnDate } }) {
const index = 3;
const young = useSelector((state) => state.Auth.young);
const isEnabled = isStepDone(STEPS.AGREEMENT, young);
const isDone = isStepDone(STEPS.CONVOCATION, 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 ModalPointagePresenceJDM
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function ModalPointagePresenceJDM({ isOpen, onSubmit, onCancel, value, young }) {
const [isLoading, setIsLoading] = React.useState(false);
const getTitle = () => {
if (value === "true") return `Marquer ${young.firstName} présent(e) à la JDM`;
- 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 12 (exceeds 5 allowed). Consider refactoring. Open
const Line = ({ hit, onClick, selected, focusedSession }) => {
const [value, setValue] = useState(null);
useEffect(() => {
setValue(hit);
- 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 AccountGeneralPage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const AccountGeneralPage = () => {
const young = useSelector((state) => state.Auth.young);
const cohort = getCohort(young.cohort);
const cantUpdatePSC1 = cohort.isAssignmentAnnouncementsOpenForYoung;
const dispatch = useDispatch();
- 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 ModalPointagePresenceArrivee
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function ModalPointagePresenceArrivee({ isOpen, onSubmit, onCancel, value, young }) {
const [isLoading, setIsLoading] = React.useState(false);
const getTitle = () => {
if (value === "true") return `Marquer ${young.firstName} présent(e)`;
- 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 Echanges
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const Echanges = () => {
const [userTickets, setUserTickets] = useState([]);
// Temporaire ils faut trouver un moyen de mieux gérer les status
const renderStatus = (status) => {
- 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 getAuthorizationToApply
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const getAuthorizationToApply = async (mission, young) => {
let refusalMessages = [];
if (isCohortTooOld(young)) {
refusalMessages.push("Le délai pour candidater est dépassé.");
}
- 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 computeYoungFilter
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function computeYoungFilter(filters, user) {
let matchs = {};
if (filters && filters.status && filters.status.length > 0) {
matchs.status = { $in: filters.status };
}
- 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 getDataInscriptions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const getDataInscriptions = async ({ department, region }) => {
let obj = { all: {}, february: {}, june: {}, july: {} };
const filter = { cohort: { $in: ["Février 2022", "Juin 2022", "Juillet 2022"] } };
if (department) filter.department = department;
if (region) filter.region = region;
- 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"