Skip to content

Commit

Permalink
🐛 Change default analyze mode to source + dependencies
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sjd78 committed Apr 5, 2024
1 parent a5d3ec4 commit 636fb1c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe("<AnalysisWizard />", () => {
/>
);

const mode = screen.getByText(/binary/i);
const mode = screen.getByText(/binary|source code/i);
await userEvent.click(mode);

const sourceCode = await screen.findByRole("option", {
Expand All @@ -126,7 +126,7 @@ describe("<AnalysisWizard />", () => {
/>
);

const mode = screen.getByText(/binary/i);
const mode = screen.getByText(/binary|source code/i);
await userEvent.click(mode);

const sourceCodePlusDependencies = await screen.findByRole("option", {
Expand Down Expand Up @@ -219,7 +219,7 @@ describe("<AnalysisWizard />", () => {
/>
);

const mode = screen.getByText(/binary/i);
const mode = screen.getByText(/binary|source code/i);
await userEvent.click(mode);

const uploadBinary = screen.queryByRole("option", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
isOpen,
}: IAnalysisWizard) => {
const { t } = useTranslation();
const title = t("dialog.title.applicationAnalysis");

const { identities } = useFetchIdentities();

Expand All @@ -108,7 +107,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
updateTaskGroup(data);
};

const onCreateTaskgroupError = (error: Error | unknown) => {
const onCreateTaskgroupError = (_error: Error | unknown) => {
pushNotification({
title: "Taskgroup creation failed",
variant: "danger",
Expand All @@ -121,14 +120,14 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
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",
Expand All @@ -143,7 +142,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
updateTaskGroup(null);
};

const onDeleteTaskgroupError = (error: Error | unknown) => {
const onDeleteTaskgroupError = (_error: Error | unknown) => {
pushNotification({
title: "Taskgroup: delete failed",
variant: "danger",
Expand All @@ -162,7 +161,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
const methods = useForm<AnalysisWizardFormValues>({
defaultValues: {
artifact: null,
mode: "binary",
mode: "source-code-deps",
formLabels: [],
selectedTargets: [],
selectedSourceLabels: [],
Expand Down Expand Up @@ -333,10 +332,12 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({

const steps = [
<WizardStep
name={t("wizard.terms.configureAnalysis")}
key="wizard-configureAnalysis"
id="wizard-configureAnalysis"
name={t("wizard.terms.configureAnalysis")}
steps={[
<WizardStep
key={StepId.AnalysisMode}
id={StepId.AnalysisMode}
name={t("wizard.terms.analysisMode")}
footer={{
Expand All @@ -352,6 +353,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
</>
</WizardStep>,
<WizardStep
key={StepId.SetTargets}
id={StepId.SetTargets}
name={t("wizard.terms.setTargets")}
isDisabled={!isStepEnabled(StepId.SetTargets)}
Expand All @@ -360,6 +362,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
<SetTargets />
</WizardStep>,
<WizardStep
key={StepId.Scope}
id={StepId.Scope}
name={t("wizard.terms.scope")}
isDisabled={!isStepEnabled(StepId.Scope)}
Expand All @@ -370,10 +373,12 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
]}
></WizardStep>,
<WizardStep
name={t("wizard.terms.advanced")}
key="wizard-advanced"
id="wizard-advanced"
name={t("wizard.terms.advanced")}
steps={[
<WizardStep
key={StepId.CustomRules}
id={StepId.CustomRules}
name={t("wizard.terms.customRules")}
isDisabled={!isStepEnabled(StepId.CustomRules)}
Expand All @@ -382,6 +387,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
<CustomRules />
</WizardStep>,
<WizardStep
key={StepId.Options}
id={StepId.Options}
name={t("wizard.terms.options")}
isDisabled={!isStepEnabled(StepId.Options)}
Expand All @@ -392,8 +398,9 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
]}
></WizardStep>,
<WizardStep
name={t("wizard.terms.review")}
key={StepId.Review}
id={StepId.Review}
name={t("wizard.terms.review")}
isDisabled={!isStepEnabled(StepId.Review)}
footer={{ nextButtonText: "Run" }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ interface ISetMode {
export const SetMode: React.FC<ISetMode> = ({ isSingleApp, isModeValid }) => {
const { t } = useTranslation();

const { watch, control, setValue } =
useFormContext<AnalysisWizardFormValues>();
const { watch, control } = useFormContext<AnalysisWizardFormValues>();
const mode = watch("mode");

const options: SelectOptionProps[] = [
Expand All @@ -41,11 +40,12 @@ export const SetMode: React.FC<ISetMode> = ({ isSingleApp, isModeValid }) => {
},
];

if (isSingleApp)
if (isSingleApp) {
options.push({
value: "binary-upload",
children: "Upload a local binary",
});
}

return (
<Form
Expand Down

0 comments on commit 636fb1c

Please sign in to comment.