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');
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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');
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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');
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Use 'undefined' instead of 'null' Open
return null;
- Read upRead up
- Exclude checks
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.
Use 'undefined' instead of 'null' Open
return null;
- Read upRead up
- Exclude checks
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()),
- Read upRead up
- Exclude checks
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()}`;
- Read upRead up
- Exclude checks
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) => {
- Read upRead up
- Exclude checks
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
$(daySelector).each((day: Day, timetableDay: CheerioElement) => {
- Read upRead up
- Exclude checks
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()}`;
- Read upRead up
- Exclude checks
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()}`;
- Read upRead up
- Exclude checks
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, moduleTimetable).text().trim(),
- Read upRead up
- Exclude checks
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
roomIds: parseRoomIds($(roomIdSelector).text()),
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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
$(weekSelector).each((_: number, row: CheerioElement) => {
- Read upRead up
- Exclude checks
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, moduleTimetable).text().trim(),
- Read upRead up
- Exclude checks
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('-');
- Read upRead up
- Exclude checks
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 weeks = weekIdString.slice(weekIdString.indexOf(':') + 1).trim().split(',');
- Read upRead up
- Exclude checks
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.