Skip to content

Commit

Permalink
FIxed Codacy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitri-Sintsov committed Oct 7, 2024
1 parent 6cc87cc commit c228c8b
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions django_jinja_knockout/static/djk/js/ajaxform.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function AjaxForm($form) {
import('./dialog.js').then(function(module) {
new module.Dialog({
'title': file.name,
'message': message,
message,
'type': BootstrapDialog.TYPE_DANGER,
}).alert();
});
Expand Down Expand Up @@ -265,7 +265,7 @@ function AjaxForm($form) {
}).catch(function (axiosError) {
if (!self.hasAlways) {
self.always();
};
}
if (typeof axiosError.request !== 'undefined') {
showAjaxError(axiosError.request, axiosError.message);
self._callbacks.error(axiosError.request, axiosError.message);
Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function Components() {
$selector.each(function(k, elem) {
component = self.get(elem);
if (componentIdx === undefined) {
componentIdx = $(elem).data('componentIdx')
componentIdx = $(elem).data('componentIdx');
desc = self.list[componentIdx];
} else if (componentIdx !== $(elem).data('componentIdx')) {
throw new Error(sprintf(
Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function Dialog(options) {
} else {
self.dialogCancel();
}
}
};
}
};

Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function Elements(options) {
Elements.getAdopted = function(tagDef) {
return function() {
tagDef.adopted.call(this);
}
};
};

Elements.setAttrs = function(attrs, isDefault) {
Expand Down
6 changes: 3 additions & 3 deletions django_jinja_knockout/static/djk/js/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ function showAjaxError(jqXHR, exception) {
var message;
if (jqXHR.status === 0) {
message = 'Not connected.\n Verify Network.';
} else if (jqXHR.status == 404) {
} else if (jqXHR.status === 404) {
message = 'Requested page not found. [404]';
} else if (jqXHR.status == 405) {
} else if (jqXHR.status === 405) {
message = 'Method not allowed. [405]';
} else if (jqXHR.status == 500) {
} else if (jqXHR.status === 500) {
message = 'Internal Server Error [500].';
} else if (exception === 'parsererror') {
message = 'Requested JSON parse failed.';
Expand Down
4 changes: 2 additions & 2 deletions django_jinja_knockout/static/djk/js/formsets.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Formset($formsTotalCount, serversideFormsCount, maxFormsCount) {
}
});
self.deleteFormHandler($elements);
}
};

} void function(Formset) {

Expand Down Expand Up @@ -170,7 +170,7 @@ function useFormsets(ko) {
$selector.findSelf('.formset').each(function(k, v) {
var $formset = $(v);
// Do not bind to display-only formsets.
if ($formset.parent('.formsets.display-only').length == 0) {
if ($formset.parent('.formsets.display-only').length === 0) {
var koFormset = $formset.popInstance('Formset');
koFormset.destroy($formset);
}
Expand Down
20 changes: 10 additions & 10 deletions django_jinja_knockout/static/djk/js/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ function Grid(options) {
self.actionTypes[type].subscribe(
self.actionTypesLength[type], this, 'arrayChange'
);
})
});
this.actions = this.iocGridActions({
owner: this,
route: this.options.pageRoute,
Expand All @@ -342,7 +342,7 @@ function Grid(options) {
this.hasSelectAllRows = ko.observable(false);
this.gridColumns = ko.observableArray();
this.iconuiColumns = ko.computed(function() {
return (this.actionTypesLength['iconui']() === 0) ? 0 : 1
return (this.actionTypesLength['iconui']() === 0) ? 0 : 1;
}, this);
this.totalColumns = ko.computed(function() {
var totalColumns = this.gridColumns().length + this.iconuiColumns();
Expand Down Expand Up @@ -410,7 +410,7 @@ function Grid(options) {
}
}
return css;
}
};

Grid.getHeaderCss = function() {
this.lastHeaderCss = mapObject(this.lastHeaderCss, function() {
Expand Down Expand Up @@ -688,8 +688,8 @@ function Grid(options) {
});
if (withKey) {
return {
'koRow': koRow,
'key': key
koRow,
key
}
} else {
return koRow;
Expand Down Expand Up @@ -1058,12 +1058,12 @@ function Grid(options) {
}
);
// Will use FkGridFilter to select filter choices.
return {cls: FkGridFilter, options: options};
return {cls: FkGridFilter, options};
};

Grid.iocKoFilter_datetime = function(filter, options) {
options.type = 'datetime';
return {cls: GridRangeFilter, options: options};
return {cls: GridRangeFilter, options};
};

Grid.iocKoFilter_date = function(filter, options) {
Expand All @@ -1073,12 +1073,12 @@ function Grid(options) {

Grid.iocKoFilter_number = function(filter, options) {
options.type = 'number';
return {cls: GridRangeFilter, options: options};
return {cls: GridRangeFilter, options};
};

Grid.iocKoFilter_choices = function(filter, options) {
options.choices = filter.choices;
return {cls: GridFilter, options: options};
return {cls: GridFilter, options};
};

Grid.createKoFilter = function(filter) {
Expand Down Expand Up @@ -1405,7 +1405,7 @@ function Grid(options) {

Grid.performAction = function(actionName, actionType, actionOptions) {
var koAction = this.getKoAction(actionName, actionType);
this.performKoAction(koAction, actionOptions)
this.performKoAction(koAction, actionOptions);
};

Grid.getCellActions = function(actionType, cellNames) {
Expand Down
4 changes: 2 additions & 2 deletions django_jinja_knockout/static/djk/js/grid/dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ function GridDialog(options) {
GridDialog.onChildGridSelectRow = function(pkVal) {
console.log('pkVal: ' + JSON.stringify(pkVal));
this.propCall('owner.onGridDialogSelectRow', {
'pkVal': pkVal,
pkVal,
'childGrid': this.grid
});
};

GridDialog.onChildGridUnselectRow = function(pkVal) {
console.log('pkVal: ' + JSON.stringify(pkVal));
this.propCall('owner.onGridDialogUnselectRow', {
'pkVal': pkVal,
pkVal,
'childGrid': this.grid
});
};
Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/grid/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function FkGridFilter(options) {
gridDialogOptions = options.fkGridOptions.dialogOptions;
delete options.fkGridOptions.dialogOptions;
}
var gridDialogOptions = $.extend({
gridDialogOptions = $.extend({
owner: this,
filterOptions: options.fkGridOptions
}, gridDialogOptions);
Expand Down
3 changes: 2 additions & 1 deletion django_jinja_knockout/static/djk/js/ioc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NestedList } from './nestedlist.js';
import { Tpl } from './tpl.js';
import { TabList } from './tabpane.js';

import { AppPost } from './url.js';
import { AjaxForms } from './ajaxform.js';

var globalIoc = new ViewModelRouter({
Expand Down Expand Up @@ -80,7 +81,7 @@ var vmRouter = new ViewModelRouter({
}
},
'post': function(viewModel) {
DjangoPost(viewModel.route, viewModel.data, viewModel.options);
AppPost(viewModel.route, viewModel.data, viewModel.options);
},
'alert' : function(viewModel) {
return import('./dialog.js').then(function(module) {
Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function Subscriber() {
if (typeof this.koSubscriptions === 'undefined') {
this.koSubscriptions = {};
}
return {'prop': prop, 'method': method, 'hash': hash};
return {prop, method, hash};
};

/**
Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/modelform.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function EditForm(options) {
var queryArgs = (this.pkUrlKwarg === null) ? {pk_val: this.pkVal} : {};
this.actions.perform(this.initialAction, {
// 'ajaxIndicator': event.currentTarget,
'queryArgs': queryArgs,
queryArgs,
});
};

Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/nestedlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function NestedList(options) {
NestedList.getElementContainer = function(k, v, level) {
return $(this.blockTags[level].itemTag)
.attr('data-nested-list-key', k)
.addClass(this.blockTags[level].itemClasses)
.addClass(this.blockTags[level].itemClasses);
};

NestedList.renderValue = function(k, v, fn, level) {
Expand Down
6 changes: 3 additions & 3 deletions django_jinja_knockout/static/djk/js/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ $.fn.autogrow = function(method) {
if ($(this).val().trim() !== '') {
update(this);
}
})
});
},
'update' : function() {
return this.each(function() {
Expand Down Expand Up @@ -552,7 +552,7 @@ $.fn.linkPreview = function(method) {
// console.log('doc.location: ' + doc.location);
// console.log('doc.location.hostname: ' + doc.location.hostname);
if (doc.body === null) {
if (doc.location.hostname == '') {
if (doc.location.hostname === '') {
// Embedded object loading random failure in Chrome 47.
// Refresh the popover content to try load it again.
$iframe.parent().html(this.getPopoverContent());
Expand Down Expand Up @@ -696,7 +696,7 @@ $.fn.scroller = function(method) {
}
if (this.maxHeight < this.scrollHeight) {
// Element already has overflow.
console.log('Scroller: element already has overflow.')
console.log('Scroller: element already has overflow.');
return 0;
}
// How much current height is lower than maximally allowed height.
Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function propGet(self, propChain, defVal, get_context) {
* thus next code is commented out:
*/
// return _.bind(propVal, parent.obj);
return function() { return {'context': parent.obj, 'fn': propVal } };
return function() { return {'context': parent.obj, 'fn': propVal }; };
}
return propVal;
}
Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function Tpl(options) {
Tpl.parentProps = ['data', 'templates'];

Tpl.init = function(options) {
var defOptions = {}
var defOptions = {};
each(this.parentProps, function(propName) {
defOptions[propName] = {};
});
Expand Down
2 changes: 1 addition & 1 deletion django_jinja_knockout/static/djk/js/vmrouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function ViewModelRouter(viewHandlers) {
this.applyHandler(viewModel, options.before[viewModel.view], bindContext);
}
// Execute registered handler.
var hasView = this.showView(viewModel, bindContext) || hasView;
hasView = this.showView(viewModel, bindContext) || hasView;
// Execute custom 'after' handler, when available.
if (typeof options.after[viewModel.view] !== 'undefined') {
this.applyHandler(viewModel, options.after[viewModel.view], bindContext);
Expand Down

0 comments on commit c228c8b

Please sign in to comment.