Reconmap/web-client

View on GitHub

Showing 102 of 450 total issues

Function updateSelectedValue has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    const updateSelectedValue = (event, id) => {
        switch (id) {
            case 'SL':
                setSkillLevelValue(event);
                break;
Severity: Major
Found in src/components/vulnerabilities/OwaspRR.jsx - About 2 hrs to fix

Function DocumentDetailsPage has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DocumentDetailsPage = () => {
    const { documentId } = useParams();
    const navigate = useNavigate();

    const [serverDoc] = useFetch(`/documents/${documentId}`)
Severity: Major
Found in src/components/documents/Details.jsx - About 2 hrs to fix

File Links.jsx has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
    faBriefcase,
    faCode,
    faCog,
    faMagnifyingGlass,
Severity: Minor
Found in src/components/layout/sidebar/Links.jsx - About 2 hrs to fix

File VulnerabilitiesTable.jsx has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Stack } from "@chakra-ui/react";
import NativeCheckbox from "components/form/NativeCheckbox";
import RestrictedComponent from "components/logic/RestrictedComponent";
import ProjectBadge from "components/projects/ProjectBadge";
import AscendingSortLink from "components/ui/AscendingSortLink";
Severity: Minor
Found in src/components/vulnerabilities/VulnerabilitiesTable.jsx - About 2 hrs to fix

Function NotificationsList has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const NotificationsList = () => {
    const [notifications, fetchNotifications] = useFetch('/notifications')

    const markNotificationAsRead = notification => {
        secureApiFetch(`/notifications/${notification.id}`, {
Severity: Minor
Found in src/components/notifications/List.jsx - About 1 hr to fix

Function TemplateDetails has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TemplateDetails = () => {
    const navigate = useNavigate();
    const { templateId } = useParams();
    const [template] = useFetch(`/projects/${templateId}`)

Severity: Minor
Found in src/components/projects/templates/Details.jsx - About 1 hr to fix

Function ProjectReport has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ProjectReport = () => {
    const { projectId } = useParams();
    const [project, setProject] = useState(null);

    useEffect(() => {
Severity: Minor
Found in src/components/projects/Report.jsx - About 1 hr to fix

Function KeyboardShortcuts has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const KeyboardShortcuts = () => {
    const [modalVisible, setModalVisible] = useState(false);

    const onKeyDownListener = useCallback((ev) => {
        if (isInputElement(document.activeElement)) {
Severity: Minor
Found in src/components/support/KeyboardShortcuts.jsx - About 1 hr to fix

Function ExportForm has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ExportForm = () => {
    const [entities] = useFetch('/system/exportables');

    const [exportButtonDisabled, setExportButtonDisabled] = useState(true);

Severity: Minor
Found in src/components/system/ExportForm.jsx - About 1 hr to fix

Function VulnerabilityEdit has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const VulnerabilityEdit = () => {
    const { vulnerabilityId } = useParams();

    const navigate = useNavigate();

Severity: Minor
Found in src/components/vulnerabilities/Edit.jsx - About 1 hr to fix

Function NotificationsBadge has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const NotificationsBadge = () => {
    const [notifications, fetchNotifications] = useFetch('/notifications?status=unread');

    const onMessageHandler = () => {
        fetchNotifications();
Severity: Minor
Found in src/components/notifications/NotificationsBadge.jsx - About 1 hr to fix

Function SystemHealthPage has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SystemHealthPage = () => {
    const wsContextData = useContext(WebsocketContext);
    const [apiHealth] = useFetch('/system/health');

    return <div>
Severity: Minor
Found in src/components/system/HealthPage.jsx - About 1 hr to fix

Function useAuth has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function useAuth() {
    const { setColorMode } = useColorMode();
    const { i18n } = useTranslation();

    const [isAuth, setIsAuth] = useState(KeyCloakService.IsAuthenticated);
Severity: Minor
Found in src/contexts/AuthContext.jsx - About 1 hr to fix

Function AuditLogList has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AuditLogList = () => {
    const navigate = useNavigate();
    const query = useQuery();
    let pageNumber = query.get('page');
    pageNumber = pageNumber !== null ? parseInt(pageNumber) : 1;
Severity: Minor
Found in src/components/auditlog/List.jsx - About 1 hr to fix

Function App has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const App = () => {
    const { user } = useAuth();

    const [theme, setTheme] = useState(user?.preferences?.['web-client.theme'] || 'dark');

Severity: Minor
Found in src/App.jsx - About 1 hr to fix

Function useDelete has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const useDelete = (endpoint, successCallback = null, confirmationMessage = `Do you really want to delete this item?`, deleteMessage = 'The item has been deleted.') => {

    return async (id) => {
        if (window.confirm(confirmationMessage)) {
            try {
Severity: Minor
Found in src/hooks/useDelete.js - About 1 hr to fix

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 VulnerabilityCreate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const VulnerabilityCreate = () => {
    const navigate = useNavigate();
    const query = useQuery();
    const urlProjectId = useRef(query.get("projectId") || 0);
    const isTemplate = "true" === query.get("isTemplate");
Severity: Minor
Found in src/components/vulnerabilities/Create.jsx - About 1 hr to fix

Function connectTerminal has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        const connectTerminal = () => {
            const agentServiceProtocol = Configuration.isSecureTransportEnabled() ? 'wss' : 'ws';
            const agentServiceHostPort = Configuration.getAgentServiceHostPort();
            const webSocket = new WebSocket(`${agentServiceProtocol}://${agentServiceHostPort}/term?token=` + user.access_token);
            webSocket.binaryType = 'arraybuffer';
Severity: Minor
Found in src/components/ui/CommandTerminal.jsx - About 1 hr to fix

Function ClientCreate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ClientCreate = () => {
    const navigate = useNavigate();
    const [newClient, setNewClient] = useState(Client);

    const onFormSubmit = async (ev) => {
Severity: Minor
Found in src/components/clients/Create.jsx - About 1 hr to fix

Function SystemIntegrationsPage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SystemIntegrationsPage = () => {
    const [integrations] = useFetch('/system/integrations')

    return <div>
        <PageTitle value="Integrations" />
Severity: Minor
Found in src/components/system/Integrations.jsx - About 1 hr to fix
Severity
Category
Status
Source
Language