GUSCRAWFORD/jyv

View on GitHub

Showing 4 of 13 total issues

Function ODataV42MongoQuery has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function ODataV42MongoQuery(odataQuery:ExpressLikeODataQuery) {
    if (JYV_CONFIG.debugMode('query')) {
        console.info(`⚙️  Converting OData-V4 Query:`);
        console.info(odataQuery);
    }
Severity: Minor
Found in mongo/src/odata-v4-2-mongo-query.ts - About 1 hr to fix

    Function ODataV42MongoFilter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function ODataV42MongoFilter(odataFilter:string, query:MongoFilter = new MongoFilter()) {
        if (odataFilter.startsWith("'")&&odataFilter.endsWith("'"))
            odataFilter = odataFilter.substring(1, odataFilter.length-1);
        var bracketedGroups = odataFilter.match(/\((.*?)\)/g);
        if (bracketedGroups && bracketedGroups.length)
    Severity: Minor
    Found in mongo/src/odata-v4-2-mongo-query.ts - About 1 hr to fix

      Function connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function connect(connection?:ConnectionInfo): Promise<MongoClient> {
          if (!connection) connection = {};
          if (!connection.host) connection.host = 'localhost';
          var userAndPwdAt = `${connection.user?(connection.user+':'):''}${(connection as any)[connection.user as string]||(connection as any).pwd?(connection as any)[(connection as any).user as string]||connection.pwd:''}`,
              mongoConnectionString = `mongodb://`
      Severity: Minor
      Found in mongo/src/odata-v4-mongodb-generic-repo.ts - About 45 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 connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function connect(connection?:ConnectionInfo): Promise<MongoClient> {
          if (!connection) connection = {};
          if (!connection.host) connection.host = 'localhost';
          var userAndPwdAt = `${connection.user?(connection.user+':'):''}${connection[connection.user]?connection[connection.user]:''}`,
              mongoConnectionString = `mongodb://`
      Severity: Minor
      Found in dynamo/src/odata-v4-dynamo-generic-repo.ts - About 45 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

      Severity
      Category
      Status
      Source
      Language