eoin-obrien/ul-timetable

View on GitHub

Showing 52 of 52 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

export async function studentTimetable(studentId: string): Promise<IStudentTimetable> {
  // Check that the student ID is valid
  if (!isValidStudentId(studentId)) {
    throw new Error('invalid student ID');
  }
Severity: Major
Found in src/api/student-timetable.ts and 2 other locations - About 5 hrs to fix
src/api/module-timetable.ts on lines 8..27
src/api/room-timetable.ts on lines 8..27

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 142.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

export async function roomTimetable(roomId: string): Promise<IRoomTimetable> {
  // Check that the room ID is valid
  if (!isValidRoomId(roomId)) {
    throw new Error('invalid room ID');
  }
Severity: Major
Found in src/api/room-timetable.ts and 2 other locations - About 5 hrs to fix
src/api/module-timetable.ts on lines 8..27
src/api/student-timetable.ts on lines 8..27

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 142.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

export async function moduleTimetable(moduleId: string): Promise<IModuleTimetable> {
  // Check that the module ID is valid
  if (!isValidModuleId(moduleId)) {
    throw new Error('invalid module ID');
  }
Severity: Major
Found in src/api/module-timetable.ts and 2 other locations - About 5 hrs to fix
src/api/room-timetable.ts on lines 8..27
src/api/student-timetable.ts on lines 8..27

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 142.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

export function parseGroups(groups: string): string[] | null {
  if (isNull(groups) || groups === '' || groups === nbspEscape) {
    return null;
  }

Severity: Major
Found in src/util/attribute-parsers.ts and 1 other location - About 1 hr to fix
src/util/attribute-parsers.ts on lines 85..91

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 66.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

export function parseModuleIds(moduleIds: string): string[] | null {
  if (isNull(moduleIds) || moduleIds === '' || moduleIds === nbspEscape) {
    return null;
  }

Severity: Major
Found in src/util/attribute-parsers.ts and 1 other location - About 1 hr to fix
src/util/attribute-parsers.ts on lines 77..83

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 66.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

When chaining calls, put method calls on new lines.
Open

  const range = (start: number, length: number) => [...Array(length).keys()].map((x: number) => String(x + start));
Severity: Minor
Found in src/util/attribute-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

    const date = `${$(dateSelector, moduleTimetable).text().trim()} ${$(timeSelector, moduleTimetable).text().trim()}`;
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

    name: he.decode($(nameSelector).text().trim()),
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

      startDate: moment.tz($(startDateSelector, row).text(), weekDateFormat, timezone).toDate(),
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

Use 'undefined' instead of 'null'
Open

    return null;
Severity: Minor
Found in src/util/attribute-parsers.ts by tslint

Rule: no-null-keyword

Disallows use of the null keyword literal.

Rationale

Instead of having the dual concepts of null andundefined in a codebase, this rule ensures that only undefined is used.

JavaScript originally intended undefined to refer to a value that doesn't yet exist, while null was meant to refer to a value that does exist but points to nothing. That's confusing. undefined is the default value when object members don't exist, and is the return value for newer native collection APIs such as Map.get when collection values don't exist.

const myObject = {};
myObject.doesNotExist; // undefined
const myMap = new Map<string number>();
myMap.get("doesNotExist"); // undefined</string>

To remove confusion over the two similar values, it's better to stick with just undefined.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-null-keyword": true

For more information see this page.

When chaining calls, put method calls on new lines.
Open

    name: he.decode($(nameSelector).text().trim()),
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

  const date = `${$(dateSelector).text().trim()} ${$(timeSelector).text().trim()}`;
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

      date: moment.tz(date, examDateFormat, timezone).toDate(),
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

      info: $(infoSelector, moduleTimetable).text().trim(),
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

      const lessonHtml = $(lesson).html();
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

  const parts = hyphenatedRoomId.toUpperCase().trim().split('-');
Severity: Minor
Found in src/util/attribute-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

Use 'undefined' instead of 'null'
Open

    return null;
Severity: Minor
Found in src/util/attribute-parsers.ts by tslint

Rule: no-null-keyword

Disallows use of the null keyword literal.

Rationale

Instead of having the dual concepts of null andundefined in a codebase, this rule ensures that only undefined is used.

JavaScript originally intended undefined to refer to a value that doesn't yet exist, while null was meant to refer to a value that does exist but points to nothing. That's confusing. undefined is the default value when object members don't exist, and is the return value for newer native collection APIs such as Map.get when collection values don't exist.

const myObject = {};
myObject.doesNotExist; // undefined
const myMap = new Map<string number>();
myMap.get("doesNotExist"); // undefined</string>

To remove confusion over the two similar values, it's better to stick with just undefined.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-null-keyword": true

For more information see this page.

When chaining calls, put method calls on new lines.
Open

    roomIds: parseRoomIds($(roomIdSelector).text()),
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

    const date = `${$(dateSelector, moduleTimetable).text().trim()} ${$(timeSelector, moduleTimetable).text().trim()}`;
Severity: Minor
Found in src/util/timetable-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

When chaining calls, put method calls on new lines.
Open

  const parts = hyphenatedRoomId.toUpperCase().trim().split('-');
Severity: Minor
Found in src/util/attribute-parsers.ts by tslint

Rule: newline-per-chained-call

Requires that chained method calls be broken apart onto separate lines.

Rationale

This style helps to keep code 'vertical', avoiding the need for side-scrolling in IDEs or text editors.

Config

Not configurable

For more information see this page.

Severity
Category
Status
Source
Language