Browse Source

[NO JIRA] Fix Code Smells

tags/10.1.0.73491
guillaume-peoch-sonarsource 11 months ago
parent
commit
48b8689538

+ 2
- 1
server/sonar-web/src/main/js/app/components/__tests__/SystemAnnouncement-test.tsx View File

@@ -36,7 +36,8 @@ jest.mock('lodash', () => {
});

it('should display system announcement', async () => {
(getValues as jest.Mock)
jest
.mocked(getValues)
.mockResolvedValueOnce([
{
key: 'sonar.announcement.displayMessage',

+ 1
- 1
server/sonar-web/src/main/js/app/components/metrics/__tests__/MetricsContextProvider-test.tsx View File

@@ -30,7 +30,7 @@ jest.mock('../../../../api/metrics', () => ({

it('should call metric', async () => {
const metrics = { coverage: mockMetric() };
(getAllMetrics as jest.Mock).mockResolvedValueOnce(Object.values(metrics));
jest.mocked(getAllMetrics).mockResolvedValueOnce(Object.values(metrics));
const wrapper = shallowRender();

expect(getAllMetrics).toHaveBeenCalled();

+ 3
- 3
server/sonar-web/src/main/js/apps/account/__tests__/Account-it.tsx View File

@@ -389,7 +389,7 @@ describe('security page', () => {
});

it("should not suggest creating a Project token if the user doesn't have at least one scannable Projects", () => {
(getScannableProjects as jest.Mock).mockResolvedValueOnce({
jest.mocked(getScannableProjects).mockResolvedValueOnce({
projects: [],
});
renderAccountApp(
@@ -402,7 +402,7 @@ describe('security page', () => {
});

it('should preselect the user token type if the user has no scan rights', async () => {
(getScannableProjects as jest.Mock).mockResolvedValueOnce({
jest.mocked(getScannableProjects).mockResolvedValueOnce({
projects: [],
});
renderAccountApp(mockLoggedInUser(), securityPagePath);
@@ -412,7 +412,7 @@ describe('security page', () => {
});

it('should preselect the only project the user has access to if they select project token', async () => {
(getScannableProjects as jest.Mock).mockResolvedValueOnce({
jest.mocked(getScannableProjects).mockResolvedValueOnce({
projects: [
{
key: 'project-key-1',

+ 1
- 1
server/sonar-web/src/main/js/apps/overview/components/App.tsx View File

@@ -69,7 +69,7 @@ export function App(props: AppProps) {
branchLike={branchLike}
branchLikes={branchLikes}
component={component}
hasAnalyses={isPending || isInProgress}
hasAnalyses={isPending ?? isInProgress}
projectBinding={projectBinding}
/>
)}

+ 1
- 1
server/sonar-web/src/main/js/apps/quality-gates/utils.ts View File

@@ -243,7 +243,7 @@ export function getPossibleOperators(metric: Metric) {
}

function metricKeyExists(key: string, metrics: Dict<Metric>) {
return metrics && metrics[key] !== undefined;
return metrics[key] !== undefined;
}

function getNoDiffMetric(metric: Metric, metrics: Dict<Metric>) {

+ 1
- 1
server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx View File

@@ -80,7 +80,7 @@ export default function UserListItem(props: UserListItemProps) {
</td>
<td className="thin nowrap text-middle">
<UserGroups
groups={user.groups || []}
groups={user.groups ?? []}
manageProvider={manageProvider}
onUpdateUsers={onUpdateUsers}
user={user}

+ 1
- 1
server/sonar-web/src/main/js/components/controls/ManagedFilter.tsx View File

@@ -38,7 +38,7 @@ export function ManagedFilter(props: ManagedFilterProps) {
return (
<div className="big-spacer-right">
<ButtonToggle
value={managed === undefined ? 'all' : managed}
value={managed ?? 'all'}
disabled={loading}
options={[
{ label: translate('all'), value: 'all' },

+ 1
- 1
server/sonar-web/src/main/js/components/rules/RuleTabViewer.tsx View File

@@ -98,7 +98,7 @@ export class RuleTabViewer extends React.PureComponent<RuleTabViewerProps, State
const query = new URLSearchParams(this.props.location.search);
if (query.has('why')) {
this.setState({
selectedTab: tabs.find((tab) => tab.key === TabKeys.WhyIsThisAnIssue) || tabs[0],
selectedTab: tabs.find((tab) => tab.key === TabKeys.WhyIsThisAnIssue) ?? tabs[0],
});
}
}

Loading…
Cancel
Save