File CSSUtils.js
has 1138 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 extractAllSelectors
has 414 lines of code (exceeds 25 allowed). Consider refactoring. Open
function extractAllSelectors(text, documentMode) {
var state, lines, lineCount,
token, style, stream, line,
selectors = [],
mode = CodeMirror.getMode({indentUnit: 2}, documentMode || "css"),
Function findSelectorAtDocumentPos
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findSelectorAtDocumentPos(editor, pos) {
var cm = editor._codeMirror;
var ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
var selector = "", foundChars = false;
var isPreprocessorDoc = isCSSPreprocessorFile(editor.document.file.fullPath);
Function _parseSelector
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _parseSelector(start, level) {
currentSelector = "";
selectorStartChar = start;
selectorStartLine = line;
Function _getRuleInfoStartingFromPropValue
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _getRuleInfoStartingFromPropValue(ctx, editorParam) {
var editor = editorParam._codeMirror || editorParam,
contextDoc = editor.document || editor.doc,
propNamePos = $.extend({}, ctx.pos),
backwardPos = $.extend({}, ctx.pos),
Function _parseDeclarationList
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _parseDeclarationList(level) {
var j;
declListStartLine = Math.min(line, lineCount - 1);
declListStartChar = stream.start;
Function _getPropNameInfo
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _getPropNameInfo(ctx) {
var propName = "",
offset = TokenUtils.offsetInToken(ctx),
tokenString = ctx.token.string,
excludedCharacters = [";", "{", "}"];
Function _getImportUrlInfo
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _getImportUrlInfo(ctx, editor) {
var backwardPos = $.extend({}, ctx.pos),
forwardPos = $.extend({}, ctx.pos),
backwardCtx,
forwardCtx,
Function _getSucceedingPropValues
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _getSucceedingPropValues(ctx, currentValue) {
var lastValue = currentValue,
propValues = [];
while (ctx.token.string !== ";" && ctx.token.string !== "}" && TokenUtils.moveNextToken(ctx)) {
Function _parseAtRule
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _parseAtRule(level) {
// reset these fields to ignore comments preceding @rules
ruleStartLine = -1;
ruleStartChar = -1;
Function _getPrecedingPropValues
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _getPrecedingPropValues(ctx) {
var lastValue = "",
curValue,
propValues = [];
while (ctx.token.string !== ":" && TokenUtils.movePrevToken(ctx)) {
Function _findAllMatchingSelectorsInText
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _findAllMatchingSelectorsInText(text, selector, mode) {
var allSelectors = extractAllSelectors(text, mode);
var result = [];
// For now, we only match the rightmost simple selector, and ignore
Function createInfo
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function createInfo(context, offset, name, index, values, isNewItem, range) {
Avoid deeply nested control flow statements. Open
if (isPreprocessorDoc && !/^\s*@/.test(selector)) {
selectorArray.push(selector);
}
Avoid deeply nested control flow statements. Open
if (!isPreprocessorDoc && _hasNonWhitespace(ctx.token.string)) {
foundChars = true;
}
Avoid deeply nested control flow statements. Open
if (state.state === "top") {
break;
}
Avoid deeply nested control flow statements. Open
} else if (ctx.token.string === "}" || ctx.token.string === ";") {
break;
}
Avoid deeply nested control flow statements. Open
if (!_parseRule(level === undefined ? 0 : level) && level > 0) {
return false;
}
Avoid deeply nested control flow statements. Open
if (isPreprocessorDoc) {
if (!skipPrevSibling && !/^\s*@/.test(selector)) {
selectorArray.unshift(selector);
}
if (skipPrevSibling) {
Avoid deeply nested control flow statements. Open
if (level > 0) {
return true;
}
Avoid deeply nested control flow statements. Open
if (!_skipProperty()) {
// We found a "{" or "}" while skipping a property. Return false to handle the
// opening or closing of a block properly.
return false;
}
Consider simplifying this complex logical expression. Open
if ((!selector && !foundChars && !isPreprocessorDoc) ||
(isPreprocessorDoc && (ctx.token.string === "" || /\s+/.test(ctx.token.string)))) {
if (TokenUtils.moveNextToken(ctx) && ctx.token.type !== "comment" && _hasNonWhitespace(ctx.token.string)) {
foundChars = true;
ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return createInfo();
Similar blocks of code found in 2 locations. Consider refactoring. Open
var testPos = {ch: ctx.pos.ch + 1, line: ctx.pos.line},
testToken = ctx.editor.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
function _nextTokenSkippingWhitespace() {
if (!_nextToken()) {
return false;
}
while (!_hasNonWhitespace(token)) {
- 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 54.
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
function _firstTokenSkippingWhitespace() {
if (!_firstToken()) {
return false;
}
while (!_hasNonWhitespace(token)) {
- 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 54.
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
if (TokenUtils.moveNextToken(ctx) &&
(ctx.token.type === "property" || ctx.token.type === "property error" ||
ctx.token.type === "tag")) {
- 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