Function getTagInfo
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getTagInfo(editor, constPos, isHtmlMode) {
// We're going to be changing pos a lot, but we don't want to mess up
// the pos the caller passed in so we use extend to make a safe copy of it.
var pos = $.extend({}, constPos),
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos),
File HTMLUtils.js
has 310 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
Function _extractAttrVal
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _extractAttrVal(ctx) {
var attrValue = ctx.token.string,
startChar = attrValue.charAt(0),
endChar = attrValue.charAt(attrValue.length - 1),
offset = TokenUtils.offsetInToken(ctx),
Function getTagAttributes
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getTagAttributes(editor, pos) {
var attrs = [],
backwardCtx = TokenUtils.getInitialContext(editor._codeMirror, pos),
forwardCtx = $.extend({}, backwardCtx);
Function findBlocks
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findBlocks(editor, modeName) {
// Start scanning from beginning of file
var ctx = TokenUtils.getInitialContext(editor._codeMirror, {line: 0, ch: 0}),
blocks = [],
currentBlock = null,
Function _getTagInfoStartingFromAttrValue
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _getTagInfoStartingFromAttrValue(ctx) {
// Assume we in the attr value
// and validate that by going backwards
var attrInfo = _extractAttrVal(ctx),
attrVal = attrInfo.val,
Function createTagInfo
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
function createTagInfo(tokenType, offset, tagName, attrName, attrValue, valueAssigned, quoteChar, hasEndQuote) {
Avoid deeply nested control flow statements. Open
} else if (forwardCtx.token.type === "error") {
if (forwardCtx.token.string.indexOf("<") === 0 || forwardCtx.token.string.indexOf(">") === 0) {
break;
}
// If we type the first letter of the next attribute, it comes as an error
Avoid deeply nested control flow statements. Open
if (offset === 0) {
TokenUtils.moveNextToken(ctx);
}
Avoid deeply nested control flow statements. Open
if (forwardCtx.token.string.indexOf("<") === 0) {
break;
}
Avoid deeply nested control flow statements. Open
if (ctx.token.string === "</") {
tokenType = CLOSING_TAG;
offset -= 2;
} else {
offset = 0;
Consider simplifying this complex logical expression. Open
if (isPriorAttr &&
(!ctx.token.type ||
(ctx.token.type && ctx.token.type !== "attribute" &&
ctx.token.type.indexOf("error") === -1 &&
ctx.token.string.indexOf("<") !== -1))) {
Avoid too many return
statements within this function. Open
return createTagInfo();
Avoid too many return
statements within this function. Open
return createTagInfo();
Avoid too many return
statements within this function. Open
return createTagInfo();
Avoid too many return
statements within this function. Open
return createTagInfo(tokenType, offset, _extractTagName(ctx));
Avoid too many return
statements within this function. Open
return createTagInfo();
Avoid too many return
statements within this function. Open
return createTagInfo();
Avoid too many return
statements within this function. Open
return createTagInfo(ATTR_NAME, offset, tagName, attrName, attrVal, true, quoteChar, hasEndQuote);
Avoid too many return
statements within this function. Open
return createTagInfo(ATTR_NAME, 0, tagInfo.tagName);
Avoid too many return
statements within this function. Open
return createTagInfo();
Avoid too many return
statements within this function. Open
return createTagInfo();
Avoid too many return
statements within this function. Open
return tagInfo;
Similar blocks of code found in 2 locations. Consider refactoring. Open
var testPos = {ch: ctx.pos.ch + 1, line: ctx.pos.line},
testToken = editor._codeMirror.getTokenAt(testPos, true);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
(tagPrefixedRegExp.test(ctx.token.type) &&
(ctx.token.string === ">" || ctx.token.string === "/>" ||
ctx.token.string === "</"))) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 46.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76