Showing 15 of 50 total issues
Function performAssertions
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function performAssertions(userDbPath: string) {
const userDbHandler = new DatabaseHandler(userDbPath);
try {
const userDb = await userDbHandler.open();
const languageManager = new LanguageManager(userDb);
Function getAllLanguageStats
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async getAllLanguageStats(): Promise<LanguageStats[]> {
const query = `
with totalExpressions as (select
languages.id as languageId,
count(languageId) as totalExpressionsCount
Function addLanguages
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function addLanguages() {
const languageNames = [
'français',
'english',
'español',
Function fillDatabasePreviousVersion
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function fillDatabasePreviousVersion(previousDb: Database) {
await clearDatabaseAndCreateSchema(previousDb);
const languageManager = new LanguageManager(previousDb);
const ideaManager = new IdeaManager(previousDb, languageManager);
Function validateContextParentheses
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function validateContextParentheses(ee: ExpressionForAdding[]) {
for (const e of ee) {
const contexts = e.text.match(/\([^)(]*\)/g) ?? [];
// No context is empty
if (contexts.some(x => x.substring(1, x.length - 1).trim().length === 0)) {
- 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 editAndTest
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function editAndTest(
newLanguage1: Language,
newLanguage2: Language,
changes: boolean,
): Promise<void> {
Function init
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public init(): void {
this.app.use('/', this.router);
if (process.env.TEST_MODE) {
// Signals that the server is running in tests
this.router.get('/', (_, res) => {
Function validateIdea
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export async function validateIdea(responseIdea: Idea, ideaForAdding: IdeaForAdding, expressionsInOrder?: ExpressionForAdding[]): Promise<void> {
expect(validate(responseIdea)).toEqual(true);
const r = await FetchUtils.fetchIdea(responseIdea.id);
const fetchedIdea = (await r.json()) as Idea;
- 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 false;
Avoid too many return
statements within this function. Open
return validateContextParentheses(ideaForAdding.ee);
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return InputValidator.isValidOrdering(ll.map(l => l.ordering));
Function validateLanguagesForEditing
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public async validateLanguagesForEditing(toValidate: unknown): Promise<boolean> {
// Object is an array
if (!Array.isArray(toValidate)) {
return false;
}
- 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 testAllGuidsDefinedOrNot
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function testAllGuidsDefinedOrNot(databasePath: string, defined: boolean) {
const dbHandler = new DatabaseHandler(databasePath);
try {
const db = await dbHandler.open();
const ideasQuery = async () => db.all(`SELECT * FROM ideas where guid is ${defined ? '' : 'not'} null`);
- 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"