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 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 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 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 splitIds = roomIdString.toUpperCase().trim().split(/\s+/g);
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.

Replace Array function with an array literal.
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: prefer-array-literal

Use array literal syntax when declaring or instantiating array types.

Notes
  • TypeScript Only

Config

Rule accepts object with next boolean options:

  • "allow-size-argument" - allows calls to Array constructor with a single element (to create empty array of a given length).
  • "allow-type-parameters" - allow Array type parameters.
Schema
{
  "type": "object",
  "properties": {
    "allow-size-argument": {
      "type": "boolean"
    },
    "allow-type-parameters": {
      "type": "boolean"
    }
  },
  "additionalProperties": false
}

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

    moduleId: $(moduleIdSelector).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

    info: $(infoSelector).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

  $(moduleTimetableSelector).each((_: number, moduleTimetable: CheerioElement) => {
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 roomIdRegex = new RegExp(`^(?:${Object.keys(buildings).join('|')})(?:${floors.join('|')})[0-9]+[A-Z]?$`, 'i');
Severity: Minor
Found in src/util/validators.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 roomIdRegex = new RegExp(`^(${Object.keys(buildings).join('|')})(${floors.join('|')})([0-9]+[A-Z]?)$`);
Severity: Minor
Found in src/api/room-details.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 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

      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.

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.

Severity
Category
Status
Source
Language