Showing 3,294 of 3,294 total issues
Function lintOneFile
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function lintOneFile(text, fullPath) {
// If a line contains only whitespace (here spaces or tabs), remove the whitespace
text = text.replace(/^[ \t]+$/gm, "");
var options = prefs.get("options");
Function checkUpdateStatus
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function checkUpdateStatus() {
var filesToCache = ['.logs'],
downloadCompleted = updateJsonHandler.get("downloadCompleted"),
updateInitiatedInPrevSession = updateJsonHandler.get("updateInitiatedInPrevSession");
Function scanTextUntil
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function scanTextUntil(cm, startCh, startLine, condition) {
var line = cm.getLine(startLine),
seen = "",
characterIndex = startCh,
currentLine = startLine,
Function _toggle
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
_toggle: function( data ) {
var toShow = data.newPanel,
toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
// handle activating a panel during the animation for another activation
Function _resetButton
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
_resetButton: function() {
if ( this.type === "input" ) {
if ( this.options.label ) {
this.element.val( this.options.label );
}
Function pulsate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.effects.effect.pulsate = function( o, done ) {
var elem = $( this ),
mode = $.effects.setMode( elem, o.mode || "show" ),
show = mode === "show",
hide = mode === "hide",
Function close
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
close: function( event ) {
var that = this,
maxZ, thisZ;
if ( !this._isOpen ) {
Function _open
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
_open: function( event, target, content ) {
if ( !content ) {
return;
}
Function assignop
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function assignop(s, f) {
symbol(s, 20).exps = true;
return infix(s, function (left, that) {
var l;
that.left = left;
Function visit
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
FileSystemEntry.prototype.visit = function (visitor, options, callback) {
if (typeof options === "function") {
callback = options;
options = {};
} else {
Function _handleSelectionKeydown
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
ColorEditor.prototype._handleSelectionKeydown = function (event) {
var hsv = {},
step = 1.5,
xOffset,
yOffset,
Function extractToVariable
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function extractToVariable(ast, start, end, text, scopes) {
var doc = session.editor.document,
editor = EditorManager.getActiveEditor(),
parentExpn = RefactoringUtils.getExpression(ast, start, end, doc.getText()),
expns = [],
Function access
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
var i = 0,
len = elems.length,
bulk = key == null;
Function showHide
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function showHide( elements, show ) {
var display, elem, hidden,
values = [],
index = 0,
length = elements.length;
Function dispatch
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
dispatch: function( event ) {
// Make a writable jQuery.Event from the native event object
event = jQuery.event.fix( event );
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 _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 hashBytes
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
hashBytes: function(data, len, seed) {
var c1 = 0xcc9e2d51, c2 = 0x1b873593;
var h1 = seed;
var roundedEnd = len & ~0x3;
Function _openReferencesPanel
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _openReferencesPanel() {
var editor = EditorManager.getActiveEditor(),
pos = editor ? editor.getCursorPos() : null,
referencesPromise,
result = new $.Deferred(),
Identical blocks of code found in 4 locations. Consider refactoring. Open
spyOn(Dialogs, 'showModalDialog').andCallFake(function (dlgClass, title, message, buttons) {
console.warn(title, message);
return {done: function (callback) { callback(Dialogs.DIALOG_BTN_OK); } };
});
- 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 63.
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