Browse Source

[NO JIRA] Fix Code Smells

tags/10.1.0.73491
guillaume-peoch-sonarsource 1 year ago
parent
commit
48b8689538

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

}); });


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

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



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


expect(getAllMetrics).toHaveBeenCalled(); expect(getAllMetrics).toHaveBeenCalled();

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

}); });


it("should not suggest creating a Project token if the user doesn't have at least one scannable Projects", () => { 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: [], projects: [],
}); });
renderAccountApp( renderAccountApp(
}); });


it('should preselect the user token type if the user has no scan rights', async () => { 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: [], projects: [],
}); });
renderAccountApp(mockLoggedInUser(), securityPagePath); renderAccountApp(mockLoggedInUser(), securityPagePath);
}); });


it('should preselect the only project the user has access to if they select project token', async () => { 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: [ projects: [
{ {
key: 'project-key-1', key: 'project-key-1',

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

branchLike={branchLike} branchLike={branchLike}
branchLikes={branchLikes} branchLikes={branchLikes}
component={component} component={component}
hasAnalyses={isPending || isInProgress}
hasAnalyses={isPending ?? isInProgress}
projectBinding={projectBinding} projectBinding={projectBinding}
/> />
)} )}

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

} }


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


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

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

</td> </td>
<td className="thin nowrap text-middle"> <td className="thin nowrap text-middle">
<UserGroups <UserGroups
groups={user.groups || []}
groups={user.groups ?? []}
manageProvider={manageProvider} manageProvider={manageProvider}
onUpdateUsers={onUpdateUsers} onUpdateUsers={onUpdateUsers}
user={user} user={user}

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

return ( return (
<div className="big-spacer-right"> <div className="big-spacer-right">
<ButtonToggle <ButtonToggle
value={managed === undefined ? 'all' : managed}
value={managed ?? 'all'}
disabled={loading} disabled={loading}
options={[ options={[
{ label: translate('all'), value: 'all' }, { label: translate('all'), value: 'all' },

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

const query = new URLSearchParams(this.props.location.search); const query = new URLSearchParams(this.props.location.search);
if (query.has('why')) { if (query.has('why')) {
this.setState({ 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