parpeoficial/stackerjs-orm

View on GitHub

Showing 8 of 22 total issues

Function makeEntityRelations has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static async makeEntityRelations(
        properties,
        entity,
        metadata,
        withs
Severity: Minor
Found in src/Util.js - About 1 hr to fix

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

        static fieldValueParser(type, value) 
        {
            if (type === "boolean") return value === 1;
            else if (type === "date") return value ? new Date(value) : null;
            else if (type === "json") 
    Severity: Minor
    Found in src/Util.js - 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 validate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async validate(entity) 
        {
            if (!await this.beforeValidate(entity)) return false;
    
            this.entity.metadata().fields.forEach(field => 
    Severity: Minor
    Found in src/BaseRepository.js - About 1 hr to fix

      Function getFieldByType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          getFieldByType(type, alias = false) 
          {
              for (let field of this.entity.metadata().fields) 
              {
                  if (field.type === type)
      Severity: Minor
      Found in src/BaseRepositoryEntities.js - About 35 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

      Avoid too many return statements within this function.
      Open

                  return value ? value * 1000 : null;
      Severity: Major
      Found in src/Util.js - About 30 mins to fix

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

            update(entity) 
            {
                let queryBuilder = DB.Factory.getQueryBuilder().update();
        
                let updatedAt = this.getFieldByType("updated_at");
        Severity: Minor
        Found in src/BaseRepository.js - 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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            async save(entity, validate = true) 
            {
                this.prepare(entity);
        
                if (validate && !await this.validate(entity)) return false;
        Severity: Minor
        Found in src/BaseRepository.js - 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 insert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            insert(entity) 
            {
                let createdAt = this.getFieldByType("created_at");
                if (createdAt)
                    entity[createdAt] = this.getCurrentTimeStamp();
        Severity: Minor
        Found in src/BaseRepository.js - 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

        Severity
        Category
        Status
        Source
        Language