Skip to content

Commit 97c09d3

Browse files
committed
fix: fix SonarQube errors
1 parent 1cc2009 commit 97c09d3

9 files changed

Lines changed: 22 additions & 24 deletions

File tree

src/actions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const fetchResource = createAction(
2121
ActionTypes.GET_RESOURCE,
2222
ApiClient.fetchResource,
2323
(resourceType: string, filters?: any, include?: string[], embed?: string[], meta?: any) => {
24-
return Object.assign({}, meta, { resourceType });
24+
return { ...meta, resourceType };
2525
}
2626
);
2727

src/actions/queueHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function queueHandler(store) {
3232
markAndSendObservation(store, item);
3333
});
3434

35-
const shouldRetryImmediately = ((opts && opts.initial === true) || store.getState().updateFlush);
35+
const shouldRetryImmediately = ((opts?.initial === true) || store.getState().updateFlush);
3636
if (shouldRetryImmediately) {
3737
_.each(timers, (_, key) => {
3838
clearTimeout(key);

src/components/LoginScreen.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ class LoginScreen extends React.Component {
3434
}
3535
handleChange(field) {
3636
return (event) => {
37-
this.setState(
38-
Object.assign(
39-
this.state,
40-
{[field]: event.target.value}
41-
));
37+
this.setState(prevState => ({
38+
...prevState,
39+
[field]: event.target.value
40+
}));
4241
};
4342
}
4443
render() {

src/components/NotFound.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const NotFound: React.FC = () => {
77
<div className="list-group facility-return clearfix">
88
<Link to="/" className="list-group-item">
99
<span className="action-icon glyphicon glyphicon-chevron-left"></span>
10-
Takaisin
10+
{' '}Takaisin
1111
</Link>
1212
</div>
1313
<h4>404 - Sivua ei löytynyt</h4>

src/components/UnitDetails.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface ObservablePropertyPanelProps {
3030
header: string;
3131
}
3232

33-
export function ObservableProperty({ quality, property, identifier, name, unitId }: ObservablePropertyProps): React.ReactElement {
33+
export function ObservableProperty({ quality, property, identifier, name, unitId }: Readonly<ObservablePropertyProps>): React.ReactElement {
3434
const url = `/unit/${unitId}/update/${property}/${identifier}`;
3535
const color = COLORS[quality] || 'primary';
3636
const icon = ICONS[identifier];
@@ -40,7 +40,7 @@ export function ObservableProperty({ quality, property, identifier, name, unitId
4040
return <Link to={url} className={buttonClassName}><span className={iconClassName}></span><br />{name.fi}</Link>;
4141
}
4242

43-
export function ObservablePropertyPanel({ allowedValues, header }: ObservablePropertyPanelProps): React.ReactElement {
43+
export function ObservablePropertyPanel({ allowedValues, header }: Readonly<ObservablePropertyPanelProps>): React.ReactElement {
4444
const amountOfValues = allowedValues.length;
4545
const cutPoint = (amountOfValues / 2) + (amountOfValues % 2);
4646
const left = allowedValues.slice(0, cutPoint);
@@ -65,7 +65,7 @@ export function ObservablePropertyPanel({ allowedValues, header }: ObservablePro
6565

6666
const UnitDetails: React.FC = () => {
6767
const params = useParams<{ unitId: string }>();
68-
const unitId = params.unitId!;
68+
const unitId = params.unitId;
6969

7070
const unit = useSelector((state: RootState) => state.data.unit[unitId]);
7171
const isLoading = useSelector((state: RootState) => state.data.loading.unit === true);

src/components/UnitHistory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class UnitHistory extends React.Component {
3737
<div className="list-group facility-return clearfix">
3838
<Link to={`/unit/${unit.id}`} className="list-group-item">
3939
<span className="action-icon glyphicon glyphicon-chevron-left"></span>
40-
Takaisin
40+
{' '}Takaisin
4141
</Link>
4242
</div>
4343
<div className="well">

src/components/UnitList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface UnitListElementProps {
1111
unit: Unit;
1212
}
1313

14-
export function UnitListElement(props: UnitListElementProps): React.ReactElement {
14+
export function UnitListElement(props: Readonly<UnitListElementProps>): React.ReactElement {
1515
const { unit } = props;
1616
const url = `/unit/${unit.id}`;
1717
let iconClassName: string;

src/util/error.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
export function CredentialError(message) {
33
this.name = 'CredentialError';
44
this.message = message;
5-
this.stack = (new Error()).stack;
5+
this.stack = (new Error(message)).stack;
66
}
77

8-
CredentialError.prototype = new Error;
8+
CredentialError.prototype = new Error('CredentialError');

src/util/time.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function minutesToHours (minutes) {
2626

2727
export function hoursToMinutes (hours) {
2828
if (typeof hours !== 'number') {
29-
hours = parseFloat(hours);
29+
hours = Number.parseFloat(hours);
3030
}
3131
return Math.floor(hours * 60);
3232
}
@@ -36,19 +36,18 @@ export function formatHours (hours) {
3636
const fract = hours % 1;
3737
let fractString;
3838
switch (fract) {
39-
case 0.75: fractString = String.fromCharCode(190); break;
40-
case 0.5: fractString = String.fromCharCode(189); break;
41-
case 0.25: fractString = String.fromCharCode(188); break;
39+
case 0.75: fractString = String.fromCodePoint(190); break;
40+
case 0.5: fractString = String.fromCodePoint(189); break;
41+
case 0.25: fractString = String.fromCodePoint(188); break;
4242
case 0: fractString = ''; break;
4343
default: return hours;
4444
}
4545
return `${full}${fractString}`;
4646
}
4747

4848

49-
export function round (floatVal, stepOption) {
50-
const step = (stepOption || 0.25);
51-
if (1 % step != 0) {
49+
export function round (floatVal, stepOption = 0.25) {
50+
if (1 % stepOption != 0) {
5251
return floatVal;
5352
}
5453

@@ -57,10 +56,10 @@ export function round (floatVal, stepOption) {
5756
const fract = num - whole;
5857

5958
let returnValue = null;
60-
const steps = _.range(step/2, 1, step);
59+
const steps = _.range(stepOption/2, 1, stepOption);
6160
for (let i = 0; i < steps.length; i++) {
6261
if (fract < steps[i]) {
63-
returnValue = whole + step * i;
62+
returnValue = whole + stepOption * i;
6463
break;
6564
}
6665
}

0 commit comments

Comments
 (0)