OpenMarshal/npm-WebDAV-Server

View on GitHub
src/server/v2/RequestContext.ts

Summary

Maintainability
A
3 hrs
Test Coverage

Function create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    static create(server : WebDAVServer, _options ?: RequestContextExternalOptions | ((error : Error, ctx : ExternalRequestContext) => void), _callback ?: (error : Error, ctx : ExternalRequestContext) => void) : ExternalRequestContext
    {
        const defaultValues = new DefaultRequestContextExternalOptions();

        const options = _options && _options.constructor !== Function ? _options as RequestContextExternalOptions : defaultValues;
Severity: Minor
Found in src/server/v2/RequestContext.ts - About 1 hr to fix

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

Function create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    static create(server : WebDAVServer, request : http.IncomingMessage, response : http.ServerResponse, _rootPath : string | ((error : Error, ctx : HTTPRequestContext) => void), _callback ?: (error : Error, ctx : HTTPRequestContext) => void) : void
    {
        const rootPath = _callback ? _rootPath as string : undefined;
        const callback = _callback ? _callback : _rootPath as ((error : Error, ctx : HTTPRequestContext) => void);

Severity: Minor
Found in src/server/v2/RequestContext.ts - About 1 hr to fix

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

Function findBestAccept has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    findBestAccept(defaultType : string = 'xml') : string
    {
        const accepts = this.find('Accept', 'text/xml').split(',');
        const regex = {
            'xml': /[^a-z0-9A-Z]xml$/,
Severity: Minor
Found in src/server/v2/RequestContext.ts - About 25 mins to fix

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

Function checkIfHeader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    checkIfHeader(_fs : FileSystem | Resource, _path : Path | (() => void), _callback ?: () => void)
    {
        const fs = _callback ? _fs as FileSystem : null;
        const path = _callback ? _path as Path : null;
        let resource = _callback ? null : _fs as Resource;
Severity: Minor
Found in src/server/v2/RequestContext.ts - About 25 mins to fix

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

Function find has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    find(name : string, defaultValue : string = null) : string
    {
        name = name.replace(/(-| )/g, '').toLowerCase();

        for(const k in this.headers)
Severity: Minor
Found in src/server/v2/RequestContext.ts - About 25 mins to fix

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

Calls to 'console.error' are not allowed.
Open

                console.error(e);
Severity: Minor
Found in src/server/v2/RequestContext.ts by tslint

Rule: no-console

Bans the use of specified console methods.

Rationale

In general, console methods aren't appropriate for production code.

Config

A list of method names to ban. If no method names are provided, all console methods are banned.

Examples
"no-console": true,log,error
Schema
{
  "type": "array",
  "items": {
    "type": "string"
  }
}

For more information see this page.

There are no issues that match your filters.

Category
Status