From 636fb1cc56e6b9ca0afcb907f5d4042de17a01b9 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Thu, 4 Apr 2024 18:38:55 -0400 Subject: [PATCH] :bug: Change default analyze mode to source + dependencies Resolves: #1364 Change the default analysis mode from "binary" to "source-code-deps". Resolve eslint warnings in touched files. Adjust unit tests. Signed-off-by: Scott J Dickerson --- .../__tests__/analysis-wizard.test.tsx | 6 ++--- .../analysis-wizard/analysis-wizard.tsx | 25 ++++++++++++------- .../applications/analysis-wizard/set-mode.tsx | 6 ++--- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/client/src/app/pages/applications/analysis-wizard/__tests__/analysis-wizard.test.tsx b/client/src/app/pages/applications/analysis-wizard/__tests__/analysis-wizard.test.tsx index e041083177..6411d1bb16 100644 --- a/client/src/app/pages/applications/analysis-wizard/__tests__/analysis-wizard.test.tsx +++ b/client/src/app/pages/applications/analysis-wizard/__tests__/analysis-wizard.test.tsx @@ -99,7 +99,7 @@ describe("", () => { /> ); - const mode = screen.getByText(/binary/i); + const mode = screen.getByText(/binary|source code/i); await userEvent.click(mode); const sourceCode = await screen.findByRole("option", { @@ -126,7 +126,7 @@ describe("", () => { /> ); - const mode = screen.getByText(/binary/i); + const mode = screen.getByText(/binary|source code/i); await userEvent.click(mode); const sourceCodePlusDependencies = await screen.findByRole("option", { @@ -219,7 +219,7 @@ describe("", () => { /> ); - const mode = screen.getByText(/binary/i); + const mode = screen.getByText(/binary|source code/i); await userEvent.click(mode); const uploadBinary = screen.queryByRole("option", { diff --git a/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx b/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx index 65db4a7afe..58096ff8d2 100644 --- a/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx +++ b/client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx @@ -93,7 +93,6 @@ export const AnalysisWizard: React.FC = ({ isOpen, }: IAnalysisWizard) => { const { t } = useTranslation(); - const title = t("dialog.title.applicationAnalysis"); const { identities } = useFetchIdentities(); @@ -108,7 +107,7 @@ export const AnalysisWizard: React.FC = ({ updateTaskGroup(data); }; - const onCreateTaskgroupError = (error: Error | unknown) => { + const onCreateTaskgroupError = (_error: Error | unknown) => { pushNotification({ title: "Taskgroup creation failed", variant: "danger", @@ -121,14 +120,14 @@ export const AnalysisWizard: React.FC = ({ onCreateTaskgroupError ); - const onSubmitTaskgroupSuccess = (data: Taskgroup) => + const onSubmitTaskgroupSuccess = (_data: Taskgroup) => pushNotification({ title: "Applications", message: "Submitted for analysis", variant: "info", }); - const onSubmitTaskgroupError = (error: Error | unknown) => + const onSubmitTaskgroupError = (_error: Error | unknown) => pushNotification({ title: "Taskgroup submit failed", variant: "danger", @@ -143,7 +142,7 @@ export const AnalysisWizard: React.FC = ({ updateTaskGroup(null); }; - const onDeleteTaskgroupError = (error: Error | unknown) => { + const onDeleteTaskgroupError = (_error: Error | unknown) => { pushNotification({ title: "Taskgroup: delete failed", variant: "danger", @@ -162,7 +161,7 @@ export const AnalysisWizard: React.FC = ({ const methods = useForm({ defaultValues: { artifact: null, - mode: "binary", + mode: "source-code-deps", formLabels: [], selectedTargets: [], selectedSourceLabels: [], @@ -333,10 +332,12 @@ export const AnalysisWizard: React.FC = ({ const steps = [ = ({ , = ({ , = ({ ]} >, = ({ , = ({ ]} >, diff --git a/client/src/app/pages/applications/analysis-wizard/set-mode.tsx b/client/src/app/pages/applications/analysis-wizard/set-mode.tsx index d3294d44aa..567fcd7782 100644 --- a/client/src/app/pages/applications/analysis-wizard/set-mode.tsx +++ b/client/src/app/pages/applications/analysis-wizard/set-mode.tsx @@ -22,8 +22,7 @@ interface ISetMode { export const SetMode: React.FC = ({ isSingleApp, isModeValid }) => { const { t } = useTranslation(); - const { watch, control, setValue } = - useFormContext(); + const { watch, control } = useFormContext(); const mode = watch("mode"); const options: SelectOptionProps[] = [ @@ -41,11 +40,12 @@ export const SetMode: React.FC = ({ isSingleApp, isModeValid }) => { }, ]; - if (isSingleApp) + if (isSingleApp) { options.push({ value: "binary-upload", children: "Upload a local binary", }); + } return (