Skip to content

Commit 0f56d4e

Browse files
fix: sonarqube detected issues (#54)
fix: sonarqube detected issues
1 parent e94997c commit 0f56d4e

12 files changed

Lines changed: 72 additions & 55 deletions

File tree

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import reactRefresh from "eslint-plugin-react-refresh";
55
import { defineConfig, globalIgnores } from "eslint/config";
66

77
export default defineConfig([
8-
globalIgnores(["dist"]),
8+
globalIgnores(["dist", "coverage"]),
99
{
1010
files: ["**/*.{js,jsx}"],
1111
extends: [

src/components/SEO.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ SEO.propTypes = {
6060
ogType: PropTypes.string,
6161
};
6262

63+
export { SEO };
6364
export default SEO;

src/components/layout/Navbar.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const Navbar = React.forwardRef(
112112
ref={combinedRef}
113113
style={{ colorScheme: "only light" }}
114114
className={cn(
115-
"sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur @supports-[backdrop-filter]:bg-background/60 px-4 md:px-6 [&_*]:no-underline",
115+
"sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur @supports-[backdrop-filter]:bg-background/60 px-4 md:px-6 **:no-underline",
116116
className
117117
)}
118118
{...props}
@@ -138,8 +138,11 @@ export const Navbar = React.forwardRef(
138138
<PopoverContent align="start" className="w-48 p-2">
139139
<NavigationMenu className="max-w-none">
140140
<NavigationMenuList className="flex-col items-start gap-1">
141-
{navigationLinks.map((link, index) => (
142-
<NavigationMenuItem key={index} className="w-full">
141+
{navigationLinks.map((link) => (
142+
<NavigationMenuItem
143+
key={link.href}
144+
className="w-full"
145+
>
143146
<Link
144147
to={link.href}
145148
className={cn(
@@ -160,8 +163,8 @@ export const Navbar = React.forwardRef(
160163
) : (
161164
<NavigationMenu className="flex">
162165
<NavigationMenuList className="gap-1">
163-
{navigationLinks.map((link, index) => (
164-
<NavigationMenuItem key={index}>
166+
{navigationLinks.map((link) => (
167+
<NavigationMenuItem key={link.href}>
165168
<Link
166169
to={link.href}
167170
className={cn(

src/components/ui/Carousel.jsx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,42 @@ function Carousel({
8080
};
8181
}, [api, onSelect]);
8282

83+
const contextValue = React.useMemo(
84+
() => ({
85+
carouselRef,
86+
api: api,
87+
opts,
88+
orientation:
89+
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
90+
scrollPrev,
91+
scrollNext,
92+
canScrollPrev,
93+
canScrollNext,
94+
}),
95+
[
96+
carouselRef,
97+
api,
98+
opts,
99+
orientation,
100+
scrollPrev,
101+
scrollNext,
102+
canScrollPrev,
103+
canScrollNext,
104+
]
105+
);
106+
83107
return (
84-
<CarouselContext.Provider
85-
value={{
86-
carouselRef,
87-
api: api,
88-
opts,
89-
orientation:
90-
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
91-
scrollPrev,
92-
scrollNext,
93-
canScrollPrev,
94-
canScrollNext,
95-
}}
96-
>
97-
<div
108+
<CarouselContext.Provider value={contextValue}>
109+
<section
98110
onKeyDownCapture={handleKeyDown}
99111
className={cn("relative", className)}
100-
role="region"
101112
aria-roledescription="carousel"
113+
aria-label="Carousel"
102114
data-slot="carousel"
103115
{...props}
104116
>
105117
{children}
106-
</div>
118+
</section>
107119
</CarouselContext.Provider>
108120
);
109121
}
@@ -134,7 +146,6 @@ function CarouselItem({ className, ...props }) {
134146

135147
return (
136148
<div
137-
role="group"
138149
aria-roledescription="slide"
139150
data-slot="carousel-item"
140151
className={cn(

src/components/ui/Form.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ const Form = FormProvider;
1717
const FormFieldContext = React.createContext({});
1818

1919
const FormField = ({ ...props }) => {
20+
const contextValue = React.useMemo(
21+
() => ({ name: props.name }),
22+
[props.name]
23+
);
24+
2025
return (
21-
<FormFieldContext.Provider value={{ name: props.name }}>
26+
<FormFieldContext.Provider value={contextValue}>
2227
<Controller {...props} />
2328
</FormFieldContext.Provider>
2429
);
@@ -51,9 +56,10 @@ const FormItemContext = React.createContext({});
5156

5257
function FormItem({ className, ...props }) {
5358
const id = React.useId();
59+
const contextValue = React.useMemo(() => ({ id }), [id]);
5460

5561
return (
56-
<FormItemContext.Provider value={{ id }}>
62+
<FormItemContext.Provider value={contextValue}>
5763
<div
5864
data-slot="form-item"
5965
className={cn("grid gap-2", className)}
@@ -86,9 +92,7 @@ function FormControl({ ...props }) {
8692
data-slot="form-control"
8793
id={formItemId}
8894
aria-describedby={
89-
!error
90-
? `${formDescriptionId}`
91-
: `${formDescriptionId} ${formMessageId}`
95+
error ? `${formDescriptionId} ${formMessageId}` : `${formDescriptionId}`
9296
}
9397
aria-invalid={!!error}
9498
{...props}

src/main.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { BrowserRouter } from "react-router-dom";
44
import "./App.css";
55
import App from "./App.jsx";
66

7-
// Use "/chrisert" for GitHub Pages, "/" for Netlify
7+
// BASE_URL comes from vite.config base: use "/chrisert" for GitHub Pages, "/" for Netlify
88
const basename = import.meta.env.BASE_URL.replace(/\/$/, "") || "/";
99

1010
// Handle GitHub Pages SPA redirect
1111
const redirect = sessionStorage.getItem("redirect");
1212
if (redirect) {
1313
sessionStorage.removeItem("redirect");
1414
// Redirect to the original path the user requested
15-
window.history.replaceState(null, "", redirect);
15+
globalThis.history.replaceState(null, "", redirect);
1616
}
1717

1818
createRoot(document.getElementById("root")).render(

src/pages/ContactPage.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Button } from "@/components/ui/Button";
66
import { Input } from "@/components/ui/Input";
77
import { Textarea } from "@/components/ui/Textarea";
88
import ContactErrorDialog from "@/components/contact/ContactErrorDialog";
9-
import SEO from "@/components/SEO";
9+
import { SEO } from "@/components/SEO";
1010
import {
1111
Form,
1212
FormControl,
@@ -21,9 +21,7 @@ const contactFormSchema = z.object({
2121
nome: z.string().min(2, {
2222
message: "O nome deve ter pelo menos 2 caracteres.",
2323
}),
24-
email: z.string().email({
25-
message: "Por favor, insira um email válido.",
26-
}),
24+
email: z.email("Por favor, insira um email válido."),
2725
telefone: z
2826
.string()
2927
.min(9, {

src/pages/FAQPage.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
AccordionItem,
66
AccordionTrigger,
77
} from "@/components/ui/accordion";
8-
import SEO from "@/components/SEO";
8+
import { SEO } from "@/components/SEO";
99
import { faqCategories, mythsAndFacts } from "@/data/faqData";
1010

1111
const FAQPage = () => {
@@ -44,10 +44,10 @@ const FAQPage = () => {
4444
collapsible
4545
className="border rounded-lg px-4"
4646
>
47-
{category.questions.map((item, index) => (
47+
{category.questions.map((item) => (
4848
<AccordionItem
49-
key={index}
50-
value={`${category.id}-${index}`}
49+
key={item.question}
50+
value={`${category.id}-${item.question}`}
5151
>
5252
<AccordionTrigger className="text-base">
5353
{item.question}
@@ -78,9 +78,9 @@ const FAQPage = () => {
7878
</div>
7979

8080
<div className="space-y-4">
81-
{mythsAndFacts.map((item, index) => (
81+
{mythsAndFacts.map((item) => (
8282
<div
83-
key={index}
83+
key={item.myth}
8484
className="bg-background rounded-lg border overflow-hidden"
8585
>
8686
<div className="grid md:grid-cols-2">

src/pages/HomePage.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Link } from "react-router-dom";
22
import { Button } from "@/components/ui/Button";
33
import { Badge } from "@/components/ui/Badge";
44
import { CTASection } from "@/components/ui/CTASection";
5-
import SEO from "@/components/SEO";
5+
import { SEO } from "@/components/SEO";
66
import { Award, Users, ThermometerSun } from "lucide-react";
77

88
const heroImage = new URL("/hero-work.jpg", import.meta.url).href;

src/pages/NotFoundPage.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Link } from "react-router-dom";
22
import { Button } from "@/components/ui/Button";
33
import { BarsScaleFadeIcon } from "@/components/ui/icons/BarsScaleFadeIcon";
4-
import SEO from "@/components/SEO";
4+
import { SEO } from "@/components/SEO";
55
import { useEffect, useState } from "react";
66

77
const NotFoundPage = () => {
@@ -10,7 +10,7 @@ const NotFoundPage = () => {
1010

1111
useEffect(() => {
1212
if (count <= 0) {
13-
window.location.replace(basename);
13+
globalThis.location.replace(basename);
1414
return;
1515
}
1616

0 commit comments

Comments
 (0)