Skip to content

Commit

Permalink
HMW-751 Fixed some of the sonarcloud items.
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwinderg committed Jun 19, 2024
1 parent 6ca52b7 commit 9e8e062
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 21 deletions.
6 changes: 3 additions & 3 deletions app/client/src/components/shared/LocationSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ function LocationSearch({ route, label }: Props) {
role="menuitem"
className={`esri-search__source esri-menu__list-item ${secondClass}`}
tabIndex="-1"
key={`source-key-${sourceIndex}`}
key={`source-key-${source.name}`}
onClick={handleSourceSelect}
onKeyDown={handleSourceSelect}
>
Expand Down Expand Up @@ -1049,7 +1049,7 @@ function LocationSearch({ route, label }: Props) {
role="menu"
data-node-ref="_suggestionListNode"
>
{filteredSuggestions.map((source, suggestIndex) => {
{filteredSuggestions.map((source) => {
function findGroupName() {
if (
source.source.name === 'ArcGIS World Geocoding Service'
Expand Down Expand Up @@ -1085,7 +1085,7 @@ function LocationSearch({ route, label }: Props) {
const title = findGroupName();
return (
<LayerSuggestions
key={`layer-suggestions-key-${suggestIndex}`}
key={`layer-suggestions-key-${source.source.name}`}
title={title}
source={source}
startIndex={layerEndIndex - (source.results.length - 1)}
Expand Down
10 changes: 7 additions & 3 deletions app/client/src/components/shared/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ type Props = {
startingExtent?: Object | null;
};

function Map({ children, layers = null, startingExtent = null }: Props) {
function Map({
children,
layers = null,
startingExtent = null,
}: Readonly<Props>) {
const { widgetLayers } = useAddSaveDataWidgetState();
const { basemap, highlightOptions, homeWidget, mapView, setMapView } =
useContext(LocationSearchContext);
Expand Down Expand Up @@ -104,7 +108,7 @@ function Map({ children, layers = null, startingExtent = null }: Props) {
view={mapView}
layers={layers}
/>
<MapMouseEvents map={map} view={mapView} />
<MapMouseEvents view={mapView} />
</>
)}
</div>
Expand All @@ -125,7 +129,7 @@ export function MapContainer(props: Props) {
);
}

export default function MapWrapper(props: Props) {
export default function MapWrapper(props: Readonly<Props>) {
return (
<FullscreenProvider>
<MapContainer {...props} />
Expand Down
10 changes: 5 additions & 5 deletions app/client/src/components/shared/MapMouseEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ import { useMapHighlightState } from 'contexts/MapHighlight';
import { useLayers } from 'contexts/Layers';
import { LocationSearchContext } from 'contexts/locationSearch';
import { useServicesContext } from 'contexts/LookupFiles';
// config
import { getPopupContent, graphicComparison } from 'utils/mapFunctions';
// types
import type {
MonitoringFeatureUpdate,
MonitoringFeatureUpdates,
WatershedAttributes,
} from 'types';
// utils
import { isInScale } from 'utils/mapFunctions';
import {
getPopupContent,
graphicComparison,
isInScale,
} from 'utils/mapFunctions';

// --- types ---
interface ClickEvent {
Expand Down Expand Up @@ -200,8 +202,6 @@ function updateGraphics(

// --- components ---
type Props = {
// map and view props auto passed from parent Map component by react-arcgis
map: any;
view: any;
};

Expand Down
12 changes: 6 additions & 6 deletions app/client/src/components/shared/MapWidgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ function MapWidgets({
view,
layers,
onHomeWidgetRendered = () => {},
}: Props) {
}: Readonly<Props>) {
const {
addSaveDataWidgetVisible,
setActiveTabIndex,
Expand Down Expand Up @@ -1278,10 +1278,10 @@ function MapWidgets({
function ShowAddSaveDataWidget({
addSaveDataWidgetVisible,
setAddSaveDataWidgetVisible,
}: {
}: Readonly<{
addSaveDataWidgetVisible: boolean;
setAddSaveDataWidgetVisible: Dispatch<SetStateAction<boolean>>;
}) {
}>) {
const [hover, setHover] = useState(false);

const clickHandler = useCallback(
Expand Down Expand Up @@ -1353,7 +1353,7 @@ function ExpandCollapse({
fullscreenActive,
setFullscreenActive,
mapViewSetter,
}: ExpandeCollapseProps) {
}: Readonly<ExpandeCollapseProps>) {
const [hover, setHover] = useState(false);

const clickHandler = useCallback(
Expand Down Expand Up @@ -1586,7 +1586,7 @@ function ShowUpstreamWatershed({
selectionActive = false,
upstreamLayer,
upstreamLoading,
}: ShowUpstreamWatershedProps) {
}: Readonly<ShowUpstreamWatershedProps>) {
const [hover, setHover] = useState(false);

const upstreamWidgetDisabled = getUpstreamWidgetDisabled();
Expand Down Expand Up @@ -2879,7 +2879,7 @@ type DownloadWidgetProps = {
view: __esri.MapView;
};

function DownloadWidget({ services, view }: DownloadWidgetProps) {
function DownloadWidget({ services, view }: Readonly<DownloadWidgetProps>) {
const layoutOptions: LayoutOptionType[] = [
{
value: 'a3-landscape',
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/components/shared/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default function Modal({
onClose = () => {},
onConfirm = () => {},
triggerElm,
}: Props) {
}: Readonly<Props>) {
const [dialogShown, setDialogShown] = useState(false);

const close = () => {
Expand Down Expand Up @@ -240,7 +240,7 @@ export function DisclaimerModal({
children,
infoIcon = false,
...props
}: DisclaimerProps) {
}: Readonly<DisclaimerProps>) {
return (
<Modal
closeTitle="Close disclaimer"
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/components/shared/ReactTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function generateFilterInput(placeholder = 'Filter column...') {
css={inputStyles}
type="text"
placeholder={placeholder}
value={filterValue ? filterValue : ''}
value={filterValue || ''}
onClick={(event) => event.stopPropagation()}
onChange={
(event) => setFilter(event.target.value || undefined) // Set undefined to remove the filter entirely
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/components/shared/Sparkline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const accessors = {
yAccessor: (d: Observation) => d.measurement,
};

export function Sparkline({ data }: { data: Observation[] }) {
export function Sparkline({ data }: Readonly<{ data: Observation[] }>) {
const color = '#ffc107';
const values = data.map((d) => d.measurement);
return (
Expand Down

0 comments on commit 9e8e062

Please sign in to comment.