Skip to content

Commit

Permalink
Quality criteria (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
alinaSielina authored Oct 9, 2023
2 parents ddeaef1 + 844df8e commit e29f817
Show file tree
Hide file tree
Showing 87 changed files with 389 additions and 409 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void RegisterCustomServices(this IServiceCollection services, ICon
{
services.AddSingleton<IResultObserver, ResultObserver>();
services.AddSingleton<IProcessReceivedDataService, ProcessReceivedDataService>();

services.AddScoped<ITextService, TextService>();
services.AddScoped<IDependencyAnalyzer, DependencyAnalyzer>();
services.AddScoped<IDbItemsRetrievalService, DbItemsRetrievalService>();
Expand All @@ -24,7 +24,6 @@ public static void RegisterCustomServices(this IServiceCollection services, ICon
services.AddScoped<IApplyChangesService, ApplyChangesService>();
services.AddScoped<ICreateTableScriptService, CreateTableScriptService>();
services.AddSingleton<IProcessReceivedDataService, ProcessReceivedDataService>();
services.AddSingleton<ResultObserver>();
services.AddScoped<ICommitFilesService, CommitFilesService>();

services.AddScoped<ISqlFormatterService, SqlFormatterService>(_ =>
Expand All @@ -46,7 +45,7 @@ public static void AddMongoDbService(this IServiceCollection services, IConfigur
{
var mongoDatabaseSection = "MongoDatabase";
var collectionName = "UserCollection";

services.Configure<MongoDatabaseConnectionSettings>(configuration.GetSection(mongoDatabaseSection)!);

services.AddTransient<IMongoService<User>>(s =>
Expand Down
1 change: 1 addition & 0 deletions frontend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"parser": "@typescript-eslint/parser",
"rules": {
"no-shadow": "off",
"no-empty-function": ["error", { "allow": ["constructors"] }],
"@angular-eslint/directive-selector": [
"error",
{
Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
"karma-chrome-launcher": "^3.1.1",
"karma-coverage": "^2.1.1",
"karma-jasmine": "^4.0.2",
"karma-jasmine-html-reporter": "~1.7.0",
"karma-jasmine-html-reporter": "1.7.0",
"prettier": "^2.7.1",
"prettier-eslint": "^15.0.1",
"typescript": "~4.7.2"
"typescript": "^4.7.2"
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/core/base/base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Subject } from 'rxjs';
export class BaseComponent implements OnDestroy {
protected unsubscribe$ = new Subject<void>();

ngOnDestroy() {
public ngOnDestroy() {
this.unsubscribe$.next();
this.unsubscribe$.complete();
}
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/core/guards/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { AuthService } from '@core/services/auth.service';
providedIn: 'root',
})
export class AuthGuard implements CanActivate, CanActivateChild {
// eslint-disable-next-line no-empty-function
constructor(private authService: AuthService, private router: Router) {}
constructor(private authService: AuthService, private router: Router) { }

public canActivate(route: ActivatedRouteSnapshot) {
return this.checkForActivation(route);
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/core/hubs/broadcast-hub.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export class BroadcastHubService {

private subscriptions: Subscription[] = [];

// eslint-disable-next-line no-empty-function
constructor(private hubFactory: SignalRHubFactoryService) {}
constructor(private hubFactory: SignalRHubFactoryService) { }

async start() {
this.hubConnection = this.hubFactory.createHub(this.hubUrl);
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/app/core/interceptors/error.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ import { catchError, switchMap } from 'rxjs/operators';
providedIn: 'root',
})
export class ErrorInterceptor implements HttpInterceptor {
// eslint-disable-next-line no-empty-function
constructor(private authService: AuthService) {}
private readonly unauthorizedErrorStatusCode = 401;

private readonly forbiddenErrorStatusCode = 403;

constructor(private authService: AuthService) { }

intercept(request: HttpRequest<unknown>, next: HttpHandler) {
return next.handle(request).pipe(
catchError((error: HttpErrorResponse) => {
if (error.status === 401 && error.headers.has('Token-Expired')) {
if (error.status === this.unauthorizedErrorStatusCode && error.headers.has('Token-Expired')) {
return this.authService.refreshTokens().pipe(switchMap(() => next.handle(request)));
}

if (error.status === 403) {
if (error.status === this.forbiddenErrorStatusCode) {
this.authService.signOut();
}

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/app/core/interceptors/jwt.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { Observable } from 'rxjs';

@Injectable()
export class JwtInterceptor implements HttpInterceptor {
// eslint-disable-next-line no-empty-function
constructor(private authService: AuthService) {}
constructor(private authService: AuthService) { }

intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
const accessToken = this.authService.getAccessToken();

if (accessToken) {
// eslint-disable-next-line no-param-reassign
request = request.clone({ setHeaders: { Authorization: `Bearer ${accessToken}` } });
const clonedRequest = request.clone({ setHeaders: { Authorization: `Bearer ${accessToken}` } });

return next.handle(clonedRequest);
}

return next.handle(request);
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/app/core/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ export class AuthService {
private ngZone: NgZone,
private spinner: SpinnerService,
private userService: UserService,
private eventService: EventService, // eslint-disable-next-line no-empty-function
) {}
private eventService: EventService,
) { }

private currentUser: UserDto | undefined;

public getUser() {
return this.currentUser
? of(this.currentUser)
: this.userService.getUserFromToken().pipe(
map((resp: any) => {
map((resp: UserDto) => {
this.currentUser = resp;
this.eventService.userChanged(this.currentUser);

Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/core/services/branch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class BranchService {
constructor(
private httpService: HttpInternalService,
private eventService: EventService,
// eslint-disable-next-line no-empty-function
) { }

public getAllBranches(projectId: number) {
Expand Down
14 changes: 5 additions & 9 deletions frontend/src/app/core/services/commit-changes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,19 @@ export class CommitChangesService {

public contentChanges$ = this.contentChangesSubject.asObservable();

constructor(
private httpService: HttpInternalService,
private notificationService: NotificationService,
// eslint-disable-next-line no-empty-function
) {}
constructor(private httpService: HttpInternalService, private notificationService: NotificationService) {}

public getContentDiffs(commitId: number, tempBlobId: string): void {
this.httpService
.getRequest<DatabaseItemContentCompare[]>(`${this.commitChangesRoute}/${commitId}/${tempBlobId}`)
.subscribe(
(contentChanges) => {
.subscribe({
next: (contentChanges) => {
this.contentChangesSubject.next(contentChanges);
},
(error) => {
error: (error) => {
this.notificationService.error(error.message);
},
);
});
}

public clearContentChanges() {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/core/services/commit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { HttpInternalService } from './http-internal.service';
export class CommitService {
private routePrefix = '/api/commit';

// eslint-disable-next-line no-empty-function
constructor(private httpService: HttpInternalService) { }
constructor(private httpService: HttpInternalService) {}

public commit(dto: CreateCommitDto) {
return this.httpService.postFullRequest(`${this.routePrefix}`, dto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { DbConnectionRemote } from '../../models/console/db-connection-remote';
export class ConsoleConnectRemoteService {
private readonly consoleConnectRoutePrefix = '/api/consoleConnect';

// eslint-disable-next-line no-empty-function
constructor(private httpService: HttpInternalService) { }
constructor(private httpService: HttpInternalService) {}

public tryConnect(dbConnectionRemote: DbConnectionRemote) {
return this.httpService.postRequest(`${this.consoleConnectRoutePrefix}/db-connect`, dbConnectionRemote);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/core/services/console-connect.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { DbConnection } from '../../models/console/db-connection';
export class ConsoleConnectService {
public baseUrl: string = environment.consoleUrl;

// eslint-disable-next-line no-empty-function
constructor(private http: HttpClient) { }

public connect(dbConnection: DbConnection) {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/core/services/database-items.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { HttpInternalService } from './http-internal.service';
export class DatabaseItemsService {
private readonly databaseItemsRoutePrefix = '/api/databaseitems';

// eslint-disable-next-line no-empty-function
constructor(private httpService: HttpInternalService) {}
constructor(private httpService: HttpInternalService) { }

public getAllItems(clientId: string): Observable<DatabaseItem[]> {
return this.httpService.getRequest<DatabaseItem[]>(`${this.databaseItemsRoutePrefix}/${clientId}`);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/core/services/database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { NewDatabaseDto } from '../../models/database/new-database-dto';
export class DatabaseService {
private readonly databaseApiUrl = '/api/projectDatabase';

// eslint-disable-next-line no-empty-function
constructor(private httpService: HttpInternalService) { }

public addDatabase(newDatabase: NewDatabaseDto) {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/core/services/files-downloader.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export class FilesDownloaderService {

private readonly staticFilesRoutePrefix = '/api/staticfiles';

// eslint-disable-next-line no-empty-function
constructor(private httpClient: HttpInternalService, private notificationService: NotificationService) {}
constructor(private httpClient: HttpInternalService, private notificationService: NotificationService) { }

public downloadSquirrelInstaller(os: OperatingSystem): void {
this.httpClient
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/app/core/services/http-internal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ export class HttpInternalService {

public headers = new HttpHeaders();

constructor(private httpClient: HttpClient) {
// Intentionally left empty; dependency injection only.
}
constructor(private httpClient: HttpClient) { }

/**
* Retrieve the current headers configuration.
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/app/core/services/load-changes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ export class LoadChangesService {

private readonly loadChangesRoutePrefix = '/api/changerecords';

constructor(private httpClient: HttpInternalService) {
// eslint-disable-next-line no-empty-function
}
constructor(private httpClient: HttpInternalService) { }

public loadChangesRequest(guid: string): Observable<string> {
return this.httpClient.postRequest<string>(`${this.loadChangesRoutePrefix}/${guid}`, null!);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/core/services/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ToastrService } from 'ngx-toastr';
providedIn: 'root',
})
export class NotificationService {
// eslint-disable-next-line no-empty-function
constructor(private toastr: ToastrService) { }

public info(content: string, title?: string) {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/core/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export class ProjectService {

private readonly projectsApiUrl = '/api/project';

// eslint-disable-next-line no-empty-function
constructor(private httpService: HttpInternalService) {}
constructor(private httpService: HttpInternalService) { }

public addProject(newProject: NewProjectDto): Observable<ProjectResponseDto> {
return this.httpService.postRequest<ProjectResponseDto>(this.projectsApiUrl, newProject);
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/core/services/script.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import { HttpInternalService } from './http-internal.service';
export class ScriptService {
private readonly scriptRoutePrefix = '/api/script';

// eslint-disable-next-line no-empty-function
constructor(private httpService: HttpInternalService) {}
constructor(private httpService: HttpInternalService) { }

public getAllScripts(projectId: number): Observable<ScriptDto[]> {
return this.httpService.getRequest(`${this.scriptRoutePrefix}/${projectId}/all`);
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/core/services/tables.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { QueryParameters } from '../../models/sql-service/query-parameters';
export class TablesService {
private readonly tableRoutePrefix = '/api/table';

// eslint-disable-next-line no-empty-function
constructor(private httpService: HttpInternalService) { }
constructor(private httpService: HttpInternalService) {}

public getAllTablesNames(query: QueryParameters) {
return this.httpService.postRequest(this.tableRoutePrefix, query);
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/core/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { HttpInternalService } from './http-internal.service';
export class UserService {
private readonly routePrefix = '/api/user';

// eslint-disable-next-line no-empty-function
constructor(private httpService: HttpInternalService) {}
constructor(private httpService: HttpInternalService) { }

public updateUserNames(dto: UpdateUserNamesDto): Observable<UserProfileDto> {
return this.httpService.putRequest<UserProfileDto>(`${this.routePrefix}/update-names`, dto);
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/app/models/commit/create-commit-dto.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TreeNode } from '@shared/components/tree/models/TreeNode.model';
import { TreeNode } from '@shared/components/tree/models/tree-node.model';

export interface CreateCommitDto {
message: string,
branchId: number,
changesGuid: string,
preScript: string,
postScript: string,
selectedItems: TreeNode[]
message: string;
branchId: number;
changesGuid: string;
preScript: string;
postScript: string;
selectedItems: TreeNode[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ import { SpinnerService } from '@core/services/spinner.service';
styleUrls: ['./authentication-page.component.sass'],
})
export class AuthenticationPageComponent {
// eslint-disable-next-line no-empty-function
constructor(private spinnerService: SpinnerService) {}
constructor(private spinnerService: SpinnerService) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ declare const google: any;
styleUrls: ['./google-button.component.sass'],
})
export class GoogleButtonComponent implements AfterViewInit {
@Input() authType = 'signin_with';
@Input() public authType = 'signin_with';

public width: string;

// eslint-disable-next-line no-empty-function
constructor(private authService: AuthService, private spinner: SpinnerService, private elementRef: ElementRef) {}
constructor(private authService: AuthService, private spinner: SpinnerService, private elementRef: ElementRef) { }

ngAfterViewInit(): void {
public ngAfterViewInit(): void {
this.spinner.show();
this.width = `${this.elementRef.nativeElement.querySelector('#signInGoogle').offsetWidth.toString()}px`;
// button rendering should be done asynchronously
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="login-container">
<div class="login-content">
<h4>Sign In</h4>
<h4 class="login-heading">Sign In</h4>

<div class="additional-sing-in">
<app-google-button authType="signin_with"></app-google-button>
Expand All @@ -26,6 +26,6 @@ <h4>Sign In</h4>
</div>

<div class="login-footer margin-top">
No account? <a routerLink="/registration">Sign Up</a>
No account? <a class="link" routerLink="/registration">Sign Up</a>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
min-width: 275px
max-width: 400px

h4
.login-heading
font-size: 24px
@extend .title

Expand All @@ -35,13 +35,13 @@
font-size: 14px
font-weight: $normal-weight

a
.link
color: $link-color

.input-wrapper
position: relative

a
.forgot-password-link
position: absolute
top: 10px
right: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class LoginComponent extends BaseComponent implements OnInit {
super();
}

ngOnInit(): void {
public ngOnInit(): void {
this.initializeForm();
}

Expand Down
Loading

0 comments on commit e29f817

Please sign in to comment.