Skip to content

Commit 3e716f0

Browse files
chore: fix sonarqube warnings
1 parent 5887eb1 commit 3e716f0

File tree

7 files changed

+13
-18
lines changed

7 files changed

+13
-18
lines changed

src/core_modules/capture-core-utils/styles/withStyles.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ type Options = {
1919
withTheme?: boolean;
2020
}
2121

22+
// Transform the raw style object with Emotion’s css() so that className={classes.label} continues to work as before
23+
const cssTransform = rawStyles => Object.keys(rawStyles).reduce((acc, key) => {
24+
acc[key] = css(rawStyles[key] as any);
25+
return acc;
26+
}, {} as any);
27+
2228
export const withStyles =
2329
<S extends Record<string, Style>, T = typeof theme>(stylesOrCreator: StylesArg<S, T>, option?: Options) =>
2430
/* Ideally, the correct type would be: Component: React.ComponentType<P>.
@@ -35,11 +41,8 @@ export const withStyles =
3541
stylesOrCreator && typeof stylesOrCreator === 'function'
3642
? stylesOrCreator(theme as T)
3743
: stylesOrCreator;
38-
// Transform the raw style object with Emotion’s css() so that className={classes.label} continues to work as before
39-
return Object.keys(rawStyles).reduce((acc, key) => {
40-
acc[key] = css(rawStyles[key] as any);
41-
return acc;
42-
}, {} as any);
44+
45+
return cssTransform(rawStyles);
4346
}, []);
4447

4548
return option?.withTheme

src/core_modules/capture-core/components/FormFields/Generic/D2TextField.component.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class D2TextField extends Component<Props> {
2222
this.handleBlur = this.handleBlur.bind(this);
2323
}
2424
instance: HTMLInputElement | null = null;
25-
containerInstance: HTMLDivElement | null = null;
2625

2726
handleChange = (payload: { value?: string }, event: any) => {
2827
this.props.onChange && this.props.onChange(payload.value || '', event);
@@ -40,7 +39,7 @@ export class D2TextField extends Component<Props> {
4039
const { onChange, onBlur, value, ...passOnProps } = this.props;
4140

4241
return (
43-
<div ref={(containerInstance) => { this.containerInstance = containerInstance; }}>
42+
<div>
4443
<Input
4544
ref={(inst: any) => { this.instance = inst; }}
4645
value={value || ''}

src/core_modules/capture-core/components/FormFields/Generic/D2TrueOnly.component.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class D2TrueOnlyPlain extends Component<Props> {
3131

3232
this.labelClasses = this.buildLabelClasses();
3333
}
34-
containerInstance: HTMLDivElement | null = null;
3534

3635
buildLabelClasses() {
3736
return {
@@ -56,7 +55,6 @@ class D2TrueOnlyPlain extends Component<Props> {
5655

5756
return (
5857
<div
59-
ref={(containerInstance) => { this.containerInstance = containerInstance; }}
6058
style={style}
6159
>
6260
<FieldSet>

src/core_modules/capture-core/components/FormFields/Options/MultiSelectBoxes/MultiSelectBoxes.component.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ type Props = OwnProps & WithStyles<typeof styles>;
2727
class MultiSelectBoxesPlain extends Component<Props> {
2828
checkedValues!: Set<any> | null;
2929
labelClasses: any;
30-
containerInstance: any;
3130

3231
constructor(props: Props) {
3332
super(props);
@@ -126,7 +125,7 @@ class MultiSelectBoxesPlain extends Component<Props> {
126125
this.setCheckedStatusForBoxes();
127126

128127
return (
129-
<div ref={(containerInstance) => { this.containerInstance = containerInstance; }}>
128+
<div>
130129
<FieldSet>
131130
{
132131
(() => {

src/core_modules/capture-core/components/FormFields/Options/SelectVirtualizedV2/OptionsSelectVirtualized.component.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ class OptionsSelectVirtualizedPlain extends React.Component<Props, State> {
7070
)) || [];
7171
}
7272

73-
containerInstance: any;
74-
7573
static defaultProps = {
7674
translations: {
7775
clearText: '',
@@ -221,7 +219,6 @@ class OptionsSelectVirtualizedPlain extends React.Component<Props, State> {
221219
return (
222220
<div
223221
data-test="virtualized-select"
224-
ref={(containerInstance) => { this.containerInstance = containerInstance; }}
225222
>
226223
<div
227224
data-test={dataTest}

src/core_modules/capture-core/components/FormFields/Options/SingleSelectBoxes/SingleSelectBoxes.component.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type Props = OwnProps & WithStyles<typeof styles>;
2626
class SingleSelectBoxesPlain extends Component<Props> {
2727
checkedValues!: Set<any> | null;
2828
labelClasses: any;
29-
containerInstance: any;
3029

3130
constructor(props: Props) {
3231
super(props);
@@ -110,7 +109,7 @@ class SingleSelectBoxesPlain extends Component<Props> {
110109
this.setCheckedStatusForBoxes();
111110

112111
return (
113-
<div ref={(containerInstance) => { this.containerInstance = containerInstance; }}>
112+
<div>
114113
<FieldSet>
115114
{
116115
(() => {

src/core_modules/capture-ui/PolygonField/DeleteControl.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ const DeleteControlPlain = ({ onClick, disabled, leaflet }: Props) => {
4343
}, [onHandleClick, disabled]);
4444

4545
useEffect(() => {
46-
leafletElement && leafletElement.addTo(leaflet.map);
46+
leafletElement?.addTo(leaflet.map);
4747
}, [leafletElement, leaflet.map]);
4848

49-
useEffect(() => () => leafletElement && leafletElement.remove(), [leafletElement]);
49+
useEffect(() => () => leafletElement?.remove(), [leafletElement]);
5050

5151
return null;
5252
};

0 commit comments

Comments
 (0)