Showing 219 of 219 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (scrollPos.scrollLeft != null) {
setScrollLeft(cm, scrollPos.scrollLeft);
if (Math.abs(cm.view.scrollLeft - startLeft) > 1) changed = 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 62.
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
Consider simplifying this complex logical expression. Open
if (options.resizeFx && RightJS.Fx && prev_panel && (swapping || loading)) {
controller.__working = true;
var unlock = function() { controller.__working = false; };
// calculating the visual effects durations
Function addChange
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addChange(cm, start, added, old, origin, fromBefore, toBefore, fromAfter, toAfter) {
var history = cm.view.history;
history.undone.length = 0;
var time = +new Date, cur = lst(history.done);
Method translatable
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def translatable *fields
if PufferPages.localize
translates *fields, fallbacks_for_empty_translations: true
translation_class.send(:include, ActiveUUID::UUID)
Function token
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
token: function(stream, state) {
if (!state.innerActive) {
var cutOff = Infinity, oldContent = stream.string;
for (var i = 0; i < n_others; ++i) {
var other = others[i];
Function highlightWorker
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function highlightWorker(cm) {
var view = cm.view, doc = view.doc;
if (view.frontier >= cm.display.showingTo) return;
var end = +new Date + cm.options.workTime;
var state = copyState(view.mode, getStateBefore(cm, view.frontier));
Method arranged
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def arranged
arranged = ActiveSupport::OrderedHash.new
insertion_points = [arranged]
depth = 0
each do |node|
- 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
Method initialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(tag_name, markup, tokens)
if markup =~ Syntax
@helper_name, @arguments, @attributes = $1, [], {}
- 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 moveVisually
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function moveVisually(line, start, dir, byUnit) {
var bidi = getOrder(line);
if (!bidi) return moveLogically(line, start, dir, byUnit);
var moveOneUnit = byUnit ? function(pos, dir) {
do pos += dir;
Function handleKeyBinding
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handleKeyBinding(cm, e) {
// Handle auto keymap transitions
var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;
clearTimeout(maybeTransition);
if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
Function keywords
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
var keywords = function(){
function kw(type) {return {type: type, style: "keyword"};}
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
Function coordsCharInner
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function coordsCharInner(cm, lineObj, lineNo, x, y) {
var innerOff = y - heightAtLine(cm, lineObj);
var wrongLine = false, cWidth = cm.display.wrapper.clientWidth;
var measurement = measureLine(cm, lineObj);
Function clear
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
TextMarker.prototype.clear = function() {
if (this.explicitlyCleared) return;
startOperation(this.cm);
var view = this.cm.view, min = null, max = null;
for (var i = 0; i < this.lines.length; ++i) {
Function findPosH
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findPosH(cm, dir, unit, visually) {
var doc = cm.view.doc, end = cm.view.sel.head, line = end.line, ch = end.ch;
var lineObj = getLine(doc, line);
function findNextLine() {
var l = line + dir;
Function cursorCoords
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function cursorCoords(cm, pos, context, lineObj, measurement) {
lineObj = lineObj || getLine(cm.view.doc, pos.line);
if (!measurement) measurement = measureLine(cm, lineObj);
function get(ch, right) {
var m = measureChar(cm, lineObj, ch, measurement);
Similar blocks of code found in 2 locations. Consider refactoring. Open
scrollLeft: function() {
if (!this.prevButton.hasClass('rui-tabs-scroller-disabled')) {
this[this.isCarousel ? 'prev' : 'justScroll'](+0.6);
}
return this;
- 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 59.
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
scrollRight: function() {
if (!this.nextButton.hasClass('rui-tabs-scroller-disabled')) {
this[this.isCarousel ? 'next' : 'justScroll'](-0.6);
}
return this;
- 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 59.
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
Function highlightLine
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function highlightLine(cm, line, state) {
// A styles array always starts with a number identifying the
// mode/overlays that it is based on (for easy invalidation).
var st = [cm.view.modeGen];
// Compute the base array of styles
Function endOperation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function endOperation(cm) {
var op = cm.curOp;
if (--op.depth) return;
cm.curOp = null;
var view = cm.view, display = cm.display;
Function indentLine
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function indentLine(cm, n, how, aggressive) {
var doc = cm.view.doc;
if (!how) how = "add";
if (how == "smart") {
if (!cm.view.mode.indent) how = "prev";