Skip to content

Commit

Permalink
fake code
Browse files Browse the repository at this point in the history
Signed-off-by: Luiz Bezerra <[email protected]>
  • Loading branch information
luluiz committed Oct 9, 2024
1 parent db55cf7 commit 9d5c01c
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// SPDX-FileCopyrightText: Copyright (C) 2023-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)<[email protected]>
// SPDX-License-Identifier: MPL-2.0

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/

import React, { useState, useEffect } from 'react';

Check failure on line 8 in packages/suite-base/src/components/ProblematicComponent/ProblematicComponent.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Replace `'react'` with `"react"`

type Props = {
Expand All @@ -10,8 +14,9 @@ type Props = {
const ProblematicComponent: React.FC<Props> = ({ userName }) => {
const [count, setCount] = useState<number>(0);
const [data, setData] = useState<any>(null);

Check failure on line 16 in packages/suite-base/src/components/ProblematicComponent/ProblematicComponent.tsx

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

Unexpected any. Specify a different type
const [unnusedData,] = useState<any>(null); // unnused var

Check failure on line 17 in packages/suite-base/src/components/ProblematicComponent/ProblematicComponent.tsx

View workflow job for this annotation

GitHub Actions / packages (ubuntu-20.04)

'unnusedData' is declared but its value is never read.

// Problema de complexidade - lógica de ramificação excessiva
// Complexity issue - bad logic
const handleClick = () => {
if (count === 0) {
setCount(count + 1);
Expand All @@ -24,15 +29,15 @@ const ProblematicComponent: React.FC<Props> = ({ userName }) => {
}
};

// Uso de "any", falta de tratamento de erro

useEffect(() => {
fetch('/api/data')
.then(async (response) => await response.json())
.then((result: any) => {
.then((result: any) => { // Using "any"
setData(result);
})
.catch((error) => {
console.log('Erro:', error); // Código que não lida adequadamente com o erro
console.log('Error:', error);
});
}, []);

Expand All @@ -41,7 +46,6 @@ const ProblematicComponent: React.FC<Props> = ({ userName }) => {
<h1>Hello, {userName}</h1>
<p>Counter: {count}</p>
<button onClick={handleClick}>Increment</button>
{/* Renderização condicional sem verificação adequada */}
{data ? <div>{data.name}</div> : <p>Loading...</p>}
</div>
);
Expand Down

0 comments on commit 9d5c01c

Please sign in to comment.