Showing 50 of 64 total issues
File parser.js
has 1198 lines of code (exceeds 250 allowed). Consider refactoring. Open
// The main Swagger parsing component that outputs refract.
import _ from 'lodash';
import { sep } from 'path';
import yaml from 'js-yaml';
Function generateElement
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
generateElement(schema) {
const {
String: StringElement,
Number: NumberElement,
Boolean: BooleanElement,
- 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
Parser
has 46 functions (exceeds 20 allowed). Consider refactoring. Open
export default class Parser {
constructor({ minim, source, generateSourceMap }) {
// Parser options
this.minim = minim;
this.source = source;
Function parse
has 123 lines of code (exceeds 25 allowed). Consider refactoring. Open
parse(done) {
const {
Category, ParseResult, SourceMap,
} = this.minim.elements;
const swaggerParser = new SwaggerParser();
Function getPosition
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
getPosition(path) {
const pieces = _.isArray(path) ? [].concat(path) : path.split('.');
let end;
let node = this.root;
let piece = pieces.shift();
- 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
Function generateElement
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
generateElement(schema) {
const {
String: StringElement,
Number: NumberElement,
Boolean: BooleanElement,
Function convertSubSchema
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
function convertSubSchema(schema, references, swagger) {
if (schema.$ref) {
references.push(schema.$ref);
return { $ref: schema.$ref };
}
- 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
Function handleSwaggerExampleRequest
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleSwaggerExampleRequest(
transaction, methodValue, transitionParams, resourceParams,
requestContentType, responseContentType, contentTypeFromProduces,
) {
let contentType = requestContentType;
Function handleSwaggerMethod
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleSwaggerMethod(resource, href, resourceParams, methodValue, method) {
const { Copy, Transition } = this.minim.elements;
const transition = new Transition();
resource.content.push(transition);
Function convertParameterToElement
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
convertParameterToElement(parameter, setAttributes = false) {
const { Array: ArrayElement, Enum: EnumElement } = this.minim.elements;
const Type = this.typeForParameter(parameter);
const schema = this.schemaForParameterValue(parameter);
- 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
Function convertParameterToElement
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
convertParameterToElement(parameter, setAttributes = false) {
const { Array: ArrayElement, Enum: EnumElement } = this.minim.elements;
const Type = this.typeForParameter(parameter);
const schema = this.schemaForParameterValue(parameter);
Function handleSwaggerExampleResponse
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleSwaggerExampleResponse(
transaction, methodValue, responseValue,
statusCode, responseBody, contentType,
) {
const { Asset, Copy } = this.minim.elements;
Function convertSubSchema
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function convertSubSchema(schema, references, swagger) {
if (schema.$ref) {
references.push(schema.$ref);
return { $ref: schema.$ref };
}
Function handleSwaggerAuth
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleSwaggerAuth() {
const { Category, AuthScheme } = this.minim.elements;
const schemes = [];
if (this.swagger.securityDefinitions) {
Function findReferences
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function findReferences(schema) {
if (schema.$ref) {
return [schema.$ref];
}
- 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
Function handleSwaggerPath
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleSwaggerPath(pathValue, href) {
const { Copy, Resource } = this.minim.elements;
const resource = new Resource();
this.withPath('paths', href, () => {
Function getPosition
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPosition(path) {
const pieces = _.isArray(path) ? [].concat(path) : path.split('.');
let end;
let node = this.root;
let piece = pieces.shift();
Function findReferences
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findReferences(schema) {
if (schema.$ref) {
return [schema.$ref];
}
Function bodyFromSchema
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function bodyFromSchema(schema, payload, parser, contentType = 'application/json') {
const dereferencedSchema = dereference(schema, schema);
const { Asset } = parser.minim.elements;
let asset = null;
Function generateObject
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
generateObject(schema) {
const {
Object: ObjectElement,
} = this.minim.elements;