Skip to content

Commit

Permalink
Small SAST fixes (#8534)
Browse files Browse the repository at this point in the history
* fix various middle-high SAST errors

* fix another small issue

* add default
  • Loading branch information
matmair authored Nov 25, 2024
1 parent 0f194af commit 5cda270
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/frontend/src/components/forms/ApiForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export function ApiForm({
// If the user has specified initial data, that overrides default values
// But, *only* for the fields we have specified
if (props.initialData) {
Object.keys(props.initialData).map((key) => {
Object.keys(props.initialData).forEach((key) => {
if (key in defaultValuesMap) {
defaultValuesMap[key] =
props?.initialData?.[key] ?? defaultValuesMap[key];
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/forms/fields/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function DateField({
let dv: Date | null = null;

if (field.value) {
dv = new Date(field.value) ?? null;
dv = new Date(field.value);
}

// Ensure that the date is valid
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/components/importer/ImporterDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default function ImporterDrawer({
// Map from import steps to stepper steps
const currentStep = useMemo(() => {
switch (session.status) {
default:
case importSessionStatus.INITIAL:
return 0;
case importSessionStatus.MAPPING:
Expand All @@ -81,6 +80,8 @@ export default function ImporterDrawer({
return 3;
case importSessionStatus.COMPLETE:
return 4;
default:
return 0;
}
}, [session.status]);

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/components/plugins/PluginUIFeature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const getPluginTemplateEditor = (
useEffect(() => {
(async () => {
try {
await func({
func({
ref: elRef.current!,
registerHandlers: ({ getCode, setCode }) => {
setCodeRef.current = setCode;
Expand Down Expand Up @@ -136,7 +136,7 @@ export const getPluginTemplatePreview = (
useEffect(() => {
(async () => {
try {
await func({
func({
ref: elRef.current!,
registerHandlers: ({ updatePreview }) => {
updatePreviewRef.current = updatePreview;
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/forms/StockForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function useStockFields({
hidden:
create ||
partInstance.trackable == false ||
(!stockItem?.quantity != undefined && stockItem?.quantity != 1)
(stockItem?.quantity != undefined && stockItem?.quantity != 1)
},
batch: {
placeholder: nextBatchCode
Expand Down
8 changes: 3 additions & 5 deletions src/frontend/src/tables/part/ParametricPartTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,10 @@ export default function ParametricPartTable({
if (column?.accessor?.toString()?.startsWith('parameter_')) {
const col = column as any;
onParameterClick(col.extra.template, record);
} else {
} else if (record?.pk) {
// Navigate through to the part detail page
if (record?.pk) {
const url = getDetailUrl(ModelType.part, record.pk);
navigateToLink(url, navigate, event);
}
const url = getDetailUrl(ModelType.part, record.pk);
navigateToLink(url, navigate, event);
}
}
}}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/tables/settings/TemplateTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export function TemplateTable({
sortable: false,
switchable: true
},
...Object.entries(additionalFormFields || {})?.map(([key, field]) => ({
...Object.entries(additionalFormFields || {}).map(([key, field]) => ({
accessor: key,
...field,
title: field.label,
Expand Down

0 comments on commit 5cda270

Please sign in to comment.