Showing 200 of 285 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
export class LandingFooterComponent {
}
- 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 45.
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
Function aiChatNonStream
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export async function aiChatNonStream(
messages: ChatMessage[],
aiProvider: AIProvider
): Promise<string> {
const provider = providers[aiProvider.name];
- 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
Hard tabs Open
|:--------------: |:-------------------------: |
- Read upRead up
- Exclude checks
MD010 - Hard tabs
Tags: whitespace, hard_tab
Aliases: no-hard-tabs
This rule is triggered by any lines that contain hard tab characters instead of using spaces for indentation. To fix this, replace any hard tab characters with spaces instead.
Example:
Some text
* hard tab character used to indent the list item
Corrected example:
Some text
* Spaces used to indent the list item instead
A space is required before "]" Open
'parts': [{ 'text': message.content }],
- Read upRead up
- Exclude checks
Rule: array-bracket-spacing
enforce consistent spacing inside array brackets
Rationale
A number of style guides require or disallow spaces between array brackets and other tokens. This rule applies to both array literals and destructuring assignments (ECMAScript 6).
Config
The rule takes one or two options. The first is a string, which can be:
-
"never"
(default) disallows spaces inside array brackets -
"always"
requires one or more spaces or newlines inside array brackets
The second option is an object for exceptions to the "never"
option:
-
"singleValue": true
requires one or more spaces or newlines inside brackets of array literals that contain a single element -
"objectsInArrays": true
requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements[ {
or} ]
-
"arraysInArrays": true
requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements[ [
or] ]
When using the "always"
option the second option takes on these exceptions:
-
"singleValue": false
disallows spaces inside brackets of array literals that contain a single element -
"objectsInArrays": false
disallows spaces between brackets of array literals and braces of their object literal elements[ {
or} ]
-
"arraysInArrays": false
disallows spaces between brackets of array literals and brackets of their array literal elements[ [
or] ]
This rule has build-in exceptions:
-
"never"
(and also the exceptions to the"always"
option) allows newlines inside array brackets, because this is a common pattern -
"always"
does not require spaces or newlines in empty array literals[]
Examples
"array-bracket-spacing":
"array-bracket-spacing": [true, "always"]
"array-bracket-spacing":
"array-bracket-spacing": [true, "never"]
"array-bracket-spacing":
"array-bracket-spacing": [true, "never", {
"arraysInArrays": true
}]
Schema
{
"anyOf": [
{
"type": "array",
"items": [
{
"enum": [
"always",
"never"
]
}
],
"minItems": 0,
"maxItems": 1
},
{
"type": "object",
"properties": {
"singleValue": {
"type": "boolean"
},
"objectsInArrays": {
"type": "boolean"
},
"arraysInArrays": {
"type": "boolean"
}
},
"additionalProperties": false
}
]
}
For more information see this page.
Multiple consecutive blank lines Open
- Read upRead up
- Exclude checks
MD012 - Multiple consecutive blank lines
Tags: whitespace, blank_lines
Aliases: no-multiple-blanks
This rule is triggered when there are multiple consecutive blank lines in the document:
Some text here
Some more text here
To fix this, delete the offending lines:
Some text here
Some more text here
Note: this rule will not be triggered if there are multiple consecutive blank lines inside code blocks.
missing whitespace Open
if(stream && aiProvider.name === 'gemini') {
- Read upRead up
- Exclude checks
Rule: whitespace
Enforces whitespace style conventions.
Rationale
Helps maintain a readable, consistent style in your codebase.
Notes
- Has Fix
Config
Several arguments may be optionally provided:
-
"check-branch"
checks branching statements (if
/else
/for
/while
) are followed by whitespace. -
"check-decl"
checks that variable declarations have whitespace around the equals token. -
"check-operator"
checks for whitespace around operator tokens. -
"check-module"
checks for whitespace in import & export statements. -
"check-separator"
checks for whitespace after separator tokens (,
/;
). -
"check-rest-spread"
checks that there is no whitespace after rest/spread operator (...
). -
"check-type"
checks for whitespace before a variable type specification. -
"check-typecast"
checks for whitespace between a typecast and its target. -
"check-type-operator"
checks for whitespace between type operators|
and&
. -
"check-preblock"
checks for whitespace before the opening brace of a block. -
"check-postbrace"
checks for whitespace after an opening brace.
Examples
"whitespace": true,check-branch,check-operator,check-typecast
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-rest-spread",
"check-type",
"check-typecast",
"check-type-operator",
"check-preblock",
"check-postbrace"
]
},
"minLength": 0,
"maxLength": 11
}
For more information see this page.
Bare URL used Open
For more information, see the docs [here](https://angular.io/guide/i18n).
- Read upRead up
- Exclude checks
MD034 - Bare URL used
Tags: links, url
Aliases: no-bare-urls
This rule is triggered whenever a URL is given that isn't surrounded by angle brackets:
For more information, see http://www.example.com/.
To fix this, add angle brackets around the URL:
For more information, see <http:></http:>.
Rationale: Without angle brackets, the URL isn't converted into a link in many markdown parsers.
Note: if you do want a bare URL without it being converted into a link, enclose it in a code block, otherwise in some markdown parsers it will be converted:
`http://www.example.com`
Trailing spaces Open
Planet Learning is designed to be available to everyone, everywhere, all the time. At the core of Planet Learning is a repository of free, open access and public domain resources to benefit all learners.
- Read upRead up
- Exclude checks
MD009 - Trailing spaces
Tags: whitespace
Aliases: no-trailing-spaces
Parameters: br_spaces (number; default: 0)
This rule is triggered on any lines that end with whitespace. To fix this, find the line that is triggered and remove any trailing spaces from the end.
The brspaces parameter allows an exception to this rule for a specific amount of trailing spaces used to insert an explicit line break/br element. For example, set brspaces to 2 to allow exactly 2 spaces at the end of a line.
Note: you have to set brspaces to 2 or higher for this exception to take effect - you can't insert a br element with just a single trailing space, so if you set brspaces to 1, the exception will be disabled, just as if it was set to the default of 0.
Trailing spaces Open
OLE maintains an on-boarding exercise for virtual interns that provides a foundation in both our software and our workflow on GitHub. Please find it here.
- Read upRead up
- Exclude checks
MD009 - Trailing spaces
Tags: whitespace
Aliases: no-trailing-spaces
Parameters: br_spaces (number; default: 0)
This rule is triggered on any lines that end with whitespace. To fix this, find the line that is triggered and remove any trailing spaces from the end.
The brspaces parameter allows an exception to this rule for a specific amount of trailing spaces used to insert an explicit line break/br element. For example, set brspaces to 2 to allow exactly 2 spaces at the end of a line.
Note: you have to set brspaces to 2 or higher for this exception to take effect - you can't insert a br element with just a single trailing space, so if you set brspaces to 1, the exception will be disabled, just as if it was set to the default of 0.
misplaced opening brace Open
{
- Read upRead up
- Exclude checks
Rule: one-line
Requires the specified tokens to be on the same line as the expression preceding them.
Notes
- Has Fix
Config
Five arguments may be optionally provided:
-
"check-catch"
checks thatcatch
is on the same line as the closing brace fortry
. -
"check-finally"
checks thatfinally
is on the same line as the closing brace forcatch
. -
"check-else"
checks thatelse
is on the same line as the closing brace forif
. -
"check-open-brace"
checks that an open brace falls on the same line as its preceding expression. -
"check-whitespace"
checks preceding whitespace for the specified tokens.
Examples
"one-line": true,check-catch,check-finally,check-else
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"check-catch",
"check-finally",
"check-else",
"check-open-brace",
"check-whitespace"
]
},
"minLength": 0,
"maxLength": 5
}
For more information see this page.
Hard tabs Open
| Name | Note |
- Read upRead up
- Exclude checks
MD010 - Hard tabs
Tags: whitespace, hard_tab
Aliases: no-hard-tabs
This rule is triggered by any lines that contain hard tab characters instead of using spaces for indentation. To fix this, replace any hard tab characters with spaces instead.
Example:
Some text
* hard tab character used to indent the list item
Corrected example:
Some text
* Spaces used to indent the list item instead
Hard tabs Open
| planet-db-port | used in the docker script |
- Read upRead up
- Exclude checks
MD010 - Hard tabs
Tags: whitespace, hard_tab
Aliases: no-hard-tabs
This rule is triggered by any lines that contain hard tab characters instead of using spaces for indentation. To fix this, replace any hard tab characters with spaces instead.
Example:
Some text
* hard tab character used to indent the list item
Corrected example:
Some text
* Spaces used to indent the list item instead
A space is required after "[" Open
'parts': [{ 'text': message.content }],
- Read upRead up
- Exclude checks
Rule: array-bracket-spacing
enforce consistent spacing inside array brackets
Rationale
A number of style guides require or disallow spaces between array brackets and other tokens. This rule applies to both array literals and destructuring assignments (ECMAScript 6).
Config
The rule takes one or two options. The first is a string, which can be:
-
"never"
(default) disallows spaces inside array brackets -
"always"
requires one or more spaces or newlines inside array brackets
The second option is an object for exceptions to the "never"
option:
-
"singleValue": true
requires one or more spaces or newlines inside brackets of array literals that contain a single element -
"objectsInArrays": true
requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements[ {
or} ]
-
"arraysInArrays": true
requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements[ [
or] ]
When using the "always"
option the second option takes on these exceptions:
-
"singleValue": false
disallows spaces inside brackets of array literals that contain a single element -
"objectsInArrays": false
disallows spaces between brackets of array literals and braces of their object literal elements[ {
or} ]
-
"arraysInArrays": false
disallows spaces between brackets of array literals and brackets of their array literal elements[ [
or] ]
This rule has build-in exceptions:
-
"never"
(and also the exceptions to the"always"
option) allows newlines inside array brackets, because this is a common pattern -
"always"
does not require spaces or newlines in empty array literals[]
Examples
"array-bracket-spacing":
"array-bracket-spacing": [true, "always"]
"array-bracket-spacing":
"array-bracket-spacing": [true, "never"]
"array-bracket-spacing":
"array-bracket-spacing": [true, "never", {
"arraysInArrays": true
}]
Schema
{
"anyOf": [
{
"type": "array",
"items": [
{
"enum": [
"always",
"never"
]
}
],
"minItems": 0,
"maxItems": 1
},
{
"type": "object",
"properties": {
"singleValue": {
"type": "boolean"
},
"objectsInArrays": {
"type": "boolean"
},
"arraysInArrays": {
"type": "boolean"
}
},
"additionalProperties": false
}
]
}
For more information see this page.
Multiple consecutive blank lines Open
- Read upRead up
- Exclude checks
MD012 - Multiple consecutive blank lines
Tags: whitespace, blank_lines
Aliases: no-multiple-blanks
This rule is triggered when there are multiple consecutive blank lines in the document:
Some text here
Some more text here
To fix this, delete the offending lines:
Some text here
Some more text here
Note: this rule will not be triggered if there are multiple consecutive blank lines inside code blocks.
Multiple consecutive blank lines Open
- Read upRead up
- Exclude checks
MD012 - Multiple consecutive blank lines
Tags: whitespace, blank_lines
Aliases: no-multiple-blanks
This rule is triggered when there are multiple consecutive blank lines in the document:
Some text here
Some more text here
To fix this, delete the offending lines:
Some text here
Some more text here
Note: this rule will not be triggered if there are multiple consecutive blank lines inside code blocks.
Multiple consecutive blank lines Open
- Read upRead up
- Exclude checks
MD012 - Multiple consecutive blank lines
Tags: whitespace, blank_lines
Aliases: no-multiple-blanks
This rule is triggered when there are multiple consecutive blank lines in the document:
Some text here
Some more text here
To fix this, delete the offending lines:
Some text here
Some more text here
Note: this rule will not be triggered if there are multiple consecutive blank lines inside code blocks.
Trailing spaces Open
**Response**:
- Read upRead up
- Exclude checks
MD009 - Trailing spaces
Tags: whitespace
Aliases: no-trailing-spaces
Parameters: br_spaces (number; default: 0)
This rule is triggered on any lines that end with whitespace. To fix this, find the line that is triggered and remove any trailing spaces from the end.
The brspaces parameter allows an exception to this rule for a specific amount of trailing spaces used to insert an explicit line break/br element. For example, set brspaces to 2 to allow exactly 2 spaces at the end of a line.
Note: you have to set brspaces to 2 or higher for this exception to take effect - you can't insert a br element with just a single trailing space, so if you set brspaces to 1, the exception will be disabled, just as if it was set to the default of 0.
Multiple consecutive blank lines Open
- Read upRead up
- Exclude checks
MD012 - Multiple consecutive blank lines
Tags: whitespace, blank_lines
Aliases: no-multiple-blanks
This rule is triggered when there are multiple consecutive blank lines in the document:
Some text here
Some more text here
To fix this, delete the offending lines:
Some text here
Some more text here
Note: this rule will not be triggered if there are multiple consecutive blank lines inside code blocks.
Hard tabs Open
| planet-db-host | used in the docker script |
- Read upRead up
- Exclude checks
MD010 - Hard tabs
Tags: whitespace, hard_tab
Aliases: no-hard-tabs
This rule is triggered by any lines that contain hard tab characters instead of using spaces for indentation. To fix this, replace any hard tab characters with spaces instead.
Example:
Some text
* hard tab character used to indent the list item
Corrected example:
Some text
* Spaces used to indent the list item instead
Bare URL used Open
(Optional: update planet.yml with specific images from https://hub.docker.com/r/treehouses/planet/tags/)
- Read upRead up
- Exclude checks
MD034 - Bare URL used
Tags: links, url
Aliases: no-bare-urls
This rule is triggered whenever a URL is given that isn't surrounded by angle brackets:
For more information, see http://www.example.com/.
To fix this, add angle brackets around the URL:
For more information, see <http:></http:>.
Rationale: Without angle brackets, the URL isn't converted into a link in many markdown parsers.
Note: if you do want a bare URL without it being converted into a link, enclose it in a code block, otherwise in some markdown parsers it will be converted:
`http://www.example.com`