Showing 15 of 21 total issues
Function respondToAccessTokenRequest
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
async respondToAccessTokenRequest(req: RequestInterface, accessTokenTTL: DateInterval): Promise<ResponseInterface> {
const client = await this.validateClient(req);
const encryptedAuthCode = this.getRequestParameter("code", req);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
AbstractGrant
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
export abstract class AbstractGrant implements GrantInterface {
protected authCodeRepository?: OAuthAuthCodeRepository;
protected userRepository?: OAuthUserRepository;
protected readonly scopeDelimiterString = " ";
protected readonly supportedGrantTypes: GrantIdentifier[] = [
Function respondToAccessTokenRequest
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
async respondToAccessTokenRequest(req: RequestInterface, accessTokenTTL: DateInterval): Promise<ResponseInterface> {
const client = await this.validateClient(req);
const encryptedAuthCode = this.getRequestParameter("code", req);
Function bootstrap
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function bootstrap() {
const prisma = new PrismaClient();
const authCodeRepository = new AuthCodeRepository(prisma);
const userRepository = new UserRepository(prisma);
Function completeAuthorizationRequest
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async completeAuthorizationRequest(authorizationRequest: AuthorizationRequest): Promise<ResponseInterface> {
if (!authorizationRequest.user || !authorizationRequest.user?.id) {
throw OAuthException.badRequest("A user must be set on the AuthorizationRequest");
}
Function enableGrantType
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
enableGrantType(toEnable: EnableGrant, accessTokenTTL: DateInterval = new DateInterval("1h")): void {
if (Array.isArray(toEnable)) {
const [grantType, ttl] = toEnable;
accessTokenTTL = ttl;
toEnable = grantType;
Function completeAuthorizationRequest
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
async completeAuthorizationRequest(authorizationRequest: AuthorizationRequest): Promise<ResponseInterface> {
if (!authorizationRequest.user) {
throw OAuthException.badRequest("A user should be set on the authorization request");
}
Function validateAuthorizationRequest
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
async validateAuthorizationRequest(request: RequestInterface): Promise<AuthorizationRequest> {
const clientId = this.getQueryStringParameter("client_id", request);
if (typeof clientId !== "string") {
throw OAuthException.invalidParameter("client_id");
Function validateAuthorizationRequest
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async validateAuthorizationRequest(request: RequestInterface): Promise<AuthorizationRequest> {
const clientId = this.getQueryStringParameter("client_id", request);
if (typeof clientId !== "string") {
throw OAuthException.invalidParameter("client_id");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validateOldRefreshToken
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async validateOldRefreshToken(request: RequestInterface, clientId: string): Promise<OAuthToken> {
const encryptedRefreshToken = this.getRequestParameter("refresh_token", request);
if (!encryptedRefreshToken) {
throw OAuthException.invalidParameter("refresh_token");
Function validateOldRefreshToken
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private async validateOldRefreshToken(request: RequestInterface, clientId: string): Promise<OAuthToken> {
const encryptedRefreshToken = this.getRequestParameter("refresh_token", request);
if (!encryptedRefreshToken) {
throw OAuthException.invalidParameter("refresh_token");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validateAuthorizationCode
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private async validateAuthorizationCode(payload: any, client: OAuthClient, request: RequestInterface) {
if (!payload.auth_code_id) {
throw OAuthException.invalidParameter("code", "Authorization code malformed");
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function completeAuthorizationRequest
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async completeAuthorizationRequest(authorizationRequest: AuthorizationRequest): Promise<ResponseInterface> {
if (!authorizationRequest.user || !authorizationRequest.user?.id) {
throw OAuthException.badRequest("A user must be set on the AuthorizationRequest");
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return;
Function enableGrantType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
enableGrantType(toEnable: EnableGrant, accessTokenTTL: DateInterval = new DateInterval("1h")): void {
if (Array.isArray(toEnable)) {
const [grantType, ttl] = toEnable;
accessTokenTTL = ttl;
toEnable = grantType;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"