Showing 34 of 97 total issues
Consider simplifying this complex logical expression. Open
Open
if (this.datasets && this.datasets.length > 1) {
var dataArray,
dataIndex;
for (var i = this.datasets.length - 1; i >= 0; i--) {
Function getDefaults
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getDefaults() {
return {
tapToDismiss: true,
toastClass: 'toast',
containerId: 'toast-container',
Function updateScaleRange
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
updateScaleRange: function(datasets){
var valuesArray = (function(){
var totalDataArray = [];
helpers.each(datasets,function(dataset){
if (dataset.data){
Function buildScale
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
buildScale : function(data){
this.scale = new Chart.RadialScale({
display: this.options.showScale,
fontStyle: this.options.scaleFontStyle,
fontSize: this.options.scaleFontSize,
Function medianPosition
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
medianPosition = (function(index) {
// Get all the points at that particular index
var Elements = [],
dataCollection,
Function set
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
NProgress.set = function(n) {
var started = NProgress.isStarted();
n = clamp(n, Settings.minimum, 1);
NProgress.status = (n === 1 ? null : n);
Function updateScaleRange
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
updateScaleRange: function(datapoints){
var valuesArray = [];
helpers.each(datapoints,function(segment){
valuesArray.push(segment.value);
});
Function draw
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
draw : function(ease){
var easeDecimal = ease || 1,
ctx = this.chart.ctx;
this.clear();
this.scale.draw();
Avoid deeply nested control flow statements. Open
Open
if (pointPosition.x - textWidth < furthestLeft) {
furthestLeft = pointPosition.x - textWidth;
furthestLeftIndex = i;
}
Function drawRoundedRectangle
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx,x,y,width,height,radius){
Avoid deeply nested control flow statements. Open
Open
for (var i=0;i<this.valuesCount;i++)
{
pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.min + (index * this.stepValue)));
if (i === 0){
ctx.moveTo(pointPosition.x, pointPosition.y);
Function animationLoop
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
animationLoop = helpers.animationLoop = function(callback,totalSteps,easingString,onProgress,onComplete,chartInstance){
Function calculateScaleRange
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly){
Method custom_bootstrap_flash
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def custom_bootstrap_flash
flash_messages = []
flash.each do |type, message|
type = 'success' if type == 'notice'
type = 'error' if type == 'alert'
- 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"