Showing 6 of 6 total issues
Function start
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function start(context: ExtensionContext, connectFn: Connect) {
function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable {
const registeredCommand: Disposable = commands.registerCommand(command, callback);
context.subscriptions.push(registeredCommand);
Function createConnection
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private createConnection(url: string, timeout: number): Promise<any> {
const _self = this;
const makeConnection: Promise<any> = new Promise((resolve, reject) => {
const socket: ISocket = _self.connectFn(url, { timeout });
Function makeConnection
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const makeConnection: Promise<any> = new Promise((resolve, reject) => {
const socket: ISocket = _self.connectFn(url, { timeout });
socket
.on('connect', () => {
resolve(new SocketIOConnection(socket, async (event: string, data: any) => {
Function getChildren
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
public getChildren(element?: SocketIOEventsItem | SocketIOEventsCollectionItem | SocketIOConnectionItem):
Array<SocketIOEventsItem | SocketIOEventsCollectionItem | SocketIOConnectionItem> {
if (!element) {
const elements: SocketIOConnectionItem[] = [];
for (const connection of this.collector.connections()) {
- 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
Consider simplifying this complex logical expression. Open
Open
if (tmp['connection'] === undefined || !(typeof tmp['connection'] === 'string')
|| tmp['event'] === undefined || !(typeof tmp['event'] === 'string')
|| tmp['index'] === undefined || !(Number.isInteger(tmp['index']))) {
throw Errors.InvalidURI;
}
Array type using 'Array<t>' is forbidden. Use 'T[]' instead.</t> Open
Open
Array<SocketIOEventsItem | SocketIOEventsCollectionItem | SocketIOConnectionItem> {
- Read upRead up
- Exclude checks
Rule: array-type
Requires using either 'T[]' or 'Array<t>' for arrays.</t>
Notes
- TypeScript Only
- Has Fix
Config
One of the following arguments must be provided:
-
"array"
enforces use ofT[]
for all types T. -
"generic"
enforces use ofArray<T>
for all types T. -
"array-simple"
enforces use ofT[]
ifT
is a simple type (primitive or type reference).
Examples
"array-type": true,array
"array-type": true,generic
"array-type": true,array-simple
Schema
{
"type": "string",
"enum": [
"array",
"generic",
"array-simple"
]
}
For more information see this page.