Showing 22 of 45 total issues
Function RequestsTable
has 524 lines of code (exceeds 150 allowed). Consider refactoring. Open
const RequestsTable = (props: RequestTableProps) => {
const { data: propData } = props;
const [data, setData] = useState<Array<ReimbursementRequest>>(propData); // Main data state
const selectItems = [
RequestStates.INCOMPLETE,
Function RequestsTable
has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring. Open
const RequestsTable = (props: RequestTableProps) => {
const { data: propData } = props;
const [data, setData] = useState<Array<ReimbursementRequest>>(propData); // Main data state
const selectItems = [
RequestStates.INCOMPLETE,
- 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 RequestForm
has 390 lines of code (exceeds 150 allowed). Consider refactoring. Open
const RequestForm = (props: RequestFormProps) => {
const {
locked,
isAdmin,
handleUpdate,
Function updateRequestState
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
export const updateRequestState = async (req: Request, res: Response) => {
const { id } = req.params;
const { employeeId, purchases, approvals, additionalComments, state, isAdmin } = req.body;
const { TESTING, FRONTEND_URL } = Constants;
const { GC_NOTIFY_ADMIN_EMAIL } = process.env;
- 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 IndividualRequest
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
const IndividualRequest = () => {
// TODO: Consolidate these states into a single state
const [reimbursementRequest, setReimbursementRequest] = useState<
ReimbursementRequest | undefined
>(undefined);
- 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
File RequestsTable.tsx
has 589 lines of code (exceeds 500 allowed). Consider refactoring. Confirmed
import {
Table,
TableBody,
TableContainer,
TableHead,
Function getFile
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
export const getFile = async (req: Request, res: Response) => {
const { id } = req.params;
const { date } = req.query;
const { TESTING } = Constants;
- 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 RequestForm
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
const RequestForm = (props: RequestFormProps) => {
const {
locked,
isAdmin,
handleUpdate,
- 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 IndividualRequest
has 179 lines of code (exceeds 150 allowed). Consider refactoring. Open
const IndividualRequest = () => {
// TODO: Consolidate these states into a single state
const [reimbursementRequest, setReimbursementRequest] = useState<
ReimbursementRequest | undefined
>(undefined);
Function UserControl
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
const UserControl = () => {
const [open, setOpen] = React.useState(false);
const anchorRef = React.useRef<HTMLButtonElement>(null);
const { state: authState, getLoginURL, getLogoutURL } = useAuthService();
const user = authState.userInfo;
- 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 Home
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const Home = () => {
const [requests, setRequests] = useState([]);
const { BACKEND_URL, FRONTEND_URL } = Constants;
const { state: authState } = useAuthService();
const isAdmin = authState.userInfo.client_roles?.includes('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 FileUpload
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Confirmed
const FileUpload = (props: FileUploadProps) => {
const { files, setFiles, index, disabled, source } = props;
const uid = Math.random().toString();
// Error notification
- 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 UserRequests
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const UserRequests = () => {
const [requests, setRequests] = useState([]);
const { BACKEND_URL } = Constants;
const { state: authState } = useAuthService();
const isAdmin = authState.userInfo.client_roles?.includes('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 getRequestByID
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const getRequestByID = async (req: Request, res: Response) => {
const { id } = req.params;
const { TESTING } = Constants;
// Projection to get everything except a file's 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 getRequestsByIDIR
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const getRequestsByIDIR = async (req: Request, res: Response) => {
const { minimal, idir } = req.query;
const { TESTING } = Constants;
if (!TESTING) {
- 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 too many return
statements within this function. Open
return data.sort((a, b) => a.submissionDate.localeCompare(b.submissionDate));
Avoid too many return
statements within this function. Open
return data.sort((a, b) =>
convertStateToStatus(b.state).localeCompare(convertStateToStatus(a.state)),
);
Avoid too many return
statements within this function. Open
return res.status(400).send('Request could not be processed.');
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return data; // Should already be sorted descending from API.