Skip to content

Commit 98c16d3

Browse files
authored
fix: further sonar issues (#1819)
* fix: issues identified by sonar Signed-off-by: Adam Setch <adam.setch@outlook.com> * fix: issues identified by sonar Signed-off-by: Adam Setch <adam.setch@outlook.com> --------- Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent 5429ce4 commit 98c16d3

File tree

8 files changed

+19
-18
lines changed

8 files changed

+19
-18
lines changed

src/renderer/components/avatars/AvatarWithFallback.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const AvatarWithFallback: React.FC<IAvatarWithFallback> = ({
2626
const [isBroken, setIsBroken] = useState(false);
2727

2828
const isNonHuman = isNonHumanUser(userType);
29+
const DefaultUserIcon = isNonHuman ? MarkGithubIcon : FeedPersonIcon;
2930

3031
// TODO explore using AnchoredOverlay component (https://primer.style/components/anchored-overlay/react/alpha) to render Avatar Card on hover
3132
return (
@@ -36,11 +37,7 @@ export const AvatarWithFallback: React.FC<IAvatarWithFallback> = ({
3637
data-testid="avatar"
3738
>
3839
{!src || isBroken ? (
39-
isNonHuman ? (
40-
<MarkGithubIcon size={size} />
41-
) : (
42-
<FeedPersonIcon size={size} />
43-
)
40+
<DefaultUserIcon size={size} />
4441
) : (
4542
<Avatar
4643
src={src}

src/renderer/components/fields/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ export const Checkbox: FC<ICheckbox> = ({
5454
<Tooltip name={`tooltip-${props.name}`} tooltip={props.tooltip} />
5555
)}
5656

57-
{counter && (
57+
{counter ? (
5858
<CounterLabel scheme={props.checked ? 'primary' : 'secondary'}>
5959
{counter}
6060
</CounterLabel>
61-
)}
61+
) : null}
6262
</Stack>
6363
)
6464
);

src/renderer/components/metrics/MetricPill.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export const MetricPill: FC<IMetricPill> = (props: IMetricPill) => {
2323
>
2424
<Stack direction="horizontal" align="center" gap="none">
2525
<props.icon size={Size.XSMALL} className={props.color} />
26-
{props.metric && <Text className="text-xxs px-1">{props.metric}</Text>}
26+
{props.metric ? (
27+
<Text className="text-xxs px-1">{props.metric}</Text>
28+
) : null}
2729
</Stack>
2830
</Label>
2931
);

src/renderer/components/notifications/NotificationRow.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ export const NotificationRow: FC<INotificationRow> = ({
8585
? `#${notification.subject.number}`
8686
: '';
8787

88-
const notificationTitle =
89-
`${notification.subject.title} ${notificationNumber && `[${notificationNumber}]`}`.trim();
88+
const notificationTitle = notificationNumber
89+
? `${notification.subject.title} [${notificationNumber}]`
90+
: notification.subject.title;
9091

9192
const groupByDate = settings.groupBy === GroupBy.DATE;
9293

src/renderer/typesGitHub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export type PullRequestReviewAuthorAssociation =
9494
| 'NONE'
9595
| 'OWNER';
9696

97-
// TODO: Add explicit types for GitHub API response vs Gitify Notifications object
97+
// TODO: #828 Add explicit types for GitHub API response vs Gitify Notifications object
9898
export type Notification = GitHubNotification & GitifyNotification;
9999

100100
export interface GitHubNotification {

src/renderer/utils/auth/utils.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ describe('renderer/utils/auth/utils.ts', () => {
101101
});
102102

103103
await expect(async () => await auth.authGitHub()).rejects.toEqual(
104-
"Oops! Something went wrong and we couldn't log you in using GitHub. Please try again. Reason: The redirect_uri is missing or invalid. Docs: https://docs.github.com/en/developers/apps/troubleshooting-oauth-errors",
104+
new Error(
105+
"Oops! Something went wrong and we couldn't log you in using GitHub. Please try again. Reason: The redirect_uri is missing or invalid. Docs: https://docs.github.com/en/developers/apps/troubleshooting-oauth-errors",
106+
),
105107
);
106108

107109
expect(openExternalLinkMock).toHaveBeenCalledTimes(1);

src/renderer/utils/auth/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export function authGitHub(
5454
});
5555
} else if (error) {
5656
reject(
57-
`Oops! Something went wrong and we couldn't log you in using GitHub. Please try again. Reason: ${errorDescription} Docs: ${errorUri}`,
57+
new Error(
58+
`Oops! Something went wrong and we couldn't log you in using GitHub. Please try again. Reason: ${errorDescription} Docs: ${errorUri}`,
59+
),
5860
);
5961
}
6062
};
@@ -257,9 +259,7 @@ export function getNewOAuthAppURL(hostname: Hostname): Link {
257259
}
258260

259261
export function isValidHostname(hostname: Hostname) {
260-
return /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/i.test(
261-
hostname,
262-
);
262+
return /^([A-Z0-9]([A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}$/i.test(hostname);
263263
}
264264

265265
export function isValidClientId(clientId: ClientID) {

src/renderer/utils/constants.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { Link } from '../types';
2-
import type { ClientID, ClientSecret, Hostname } from '../types';
1+
import type { ClientID, ClientSecret, Hostname, Link } from '../types';
32

43
export const Constants = {
54
REPO_SLUG: 'gitify-app/gitify',

0 commit comments

Comments
 (0)