scitran/core

View on GitHub
swagger/support/schema-transpiler.js

Summary

Maintainability
C
7 hrs
Test Coverage

Function draft4ToOpenApi2 has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

SchemaTranspiler.prototype.draft4ToOpenApi2 = function(schema, defs, id) {
    var ref, defname;

    // Drop the $schema property, and make a copy
    schema = _.omit(schema, OMITTED_PROPERTIES);
Severity: Minor
Found in swagger/support/schema-transpiler.js - About 3 hrs 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 draft4ToOpenApi2 has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

SchemaTranspiler.prototype.draft4ToOpenApi2 = function(schema, defs, id) {
    var ref, defname;

    // Drop the $schema property, and make a copy
    schema = _.omit(schema, OMITTED_PROPERTIES);
Severity: Minor
Found in swagger/support/schema-transpiler.js - About 1 hr to fix

    Function _mergeExampleWithRef has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    SchemaTranspiler.prototype._mergeExampleWithRef = function(schema, defs, id) {
        var ref, m;
        if( defs ) {
            m = RE_LOCAL_REF.exec(schema.$ref);
            if( m ) {
    Severity: Minor
    Found in swagger/support/schema-transpiler.js - About 55 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 _resolveRef has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    SchemaTranspiler.prototype._resolveRef = function(schema, defs) {
        var m, ref;
        
        if( !defs ) {
            if( schema.$ref ) {
    Severity: Minor
    Found in swagger/support/schema-transpiler.js - 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 _mergeAnyOrOneOf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    SchemaTranspiler.prototype._mergeAnyOrOneOf = function(schema, defs, key, id) {
        var items = schema[key];
        delete schema[key];
    
        items = _.map(items, function(item) {
    Severity: Minor
    Found in swagger/support/schema-transpiler.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

    There are no issues that match your filters.

    Category
    Status