Showing 24 of 626 total issues
Function tabulatrInitialize
has 218 lines of code (exceeds 25 allowed). Consider refactoring. Open
function tabulatrInitialize() {
tabulatr_tables = [];
$('th.tabulatr-sortable').click(function(){
var th = $(this);
Function updatePagination
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
updatePagination: function(currentPage){
var $paginatorUl = $('.pagination[data-table='+ this.tableId +'] > ul');
$paginatorUl.html(this.createResetButton());
if(this.pageCount < 13){
for(var i = 1; i <= this.pageCount; i++){
- 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
File _tabulatr.js
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
function Tabulatr(id){
this.id = id;
this.name = '';
this.moreResults = true;
this.currentData = null;
prototype
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
Tabulatr.prototype = {
constructor: Tabulatr,
updateTable: function(hash, forceReload) {
var $table = $('#'+ this.id);
Function updatePagination
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
updatePagination: function(currentPage){
var $paginatorUl = $('.pagination[data-table='+ this.tableId +'] > ul');
$paginatorUl.html(this.createResetButton());
if(this.pageCount < 13){
for(var i = 1; i <= this.pageCount; i++){
Function insertTabulatrData
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
insertTabulatrData: function(response){
if (typeof response === "string")
response = JSON.parse(response);
var tableId = response.meta.table_id;
Method apply_sorting
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def apply_sorting(sortparam)
if sortparam.present?
clname, orientation = sortparam.split(' ')
if clname[':']
splitted = clname.split(':')
- 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 apply_filters
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def apply_filters(filter_params)
default_filters = table_columns.map do |col|
next if col.col_options.default_filter.nil?
["#{col.table_name}:#{col.name}", col.col_options.default_filter]
end.compact.to_h
- 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 retrieveTableFromLocalStorage
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Tabulatr.prototype.retrieveTableFromLocalStorage = function(response){
try {
var currentStorage = JSON.parse(localStorage[this.id]);
if(currentStorage !== undefined){
$('.pagination[data-table='+ this.id +'] a[data-page='+ response.meta.page +']');
Method data_for_table
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def data_for_table(params, locals: {}, default_order: nil, controller: nil, &block)
@batch_actions = block if block_given?
@controller = controller
@default_order = default_order
Function getDataForAjax
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
getDataForAjax: function(hash){
var data;
if(this.initialRequest && this.isAPersistedTable && localStorage[this.id]){
data = JSON.parse(localStorage[this.id]);
}else{
- 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 tabulatr_for
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def tabulatr_for(relation, tabulatr_data_class: nil, serializer: nil, render_action: nil, default_order: nil, locals: {}, &block)
klass = relation.respond_to?(:klass) ? relation.klass : relation
locals[:current_user] ||= current_user if respond_to?(:current_user)
if batch_params(klass, params).present?
response = klass.tabulatr(relation, tabulatr_data_class).data_for_table(params, locals: locals, controller: self, &block)
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(relation)
@relation = relation
@base = self.class.main_class rescue nil
@base ||= relation.respond_to?(:klass) ? relation.klass : relation
@table_name = @base.table_name
- 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 tabulatrInitialize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function tabulatrInitialize() {
tabulatr_tables = [];
$('th.tabulatr-sortable').click(function(){
var th = $(this);
- 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 apply_search
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def apply_search(query)
like ||= Tabulatr::Utility.like_statement
return unless query.present?
if @search.is_a? Array
query = query.strip.gsub(/['*%\s]+/, '%')
- 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 build_hash_from
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.build_hash_from requested_attributes, id
attrs = []
id_included = false
requested_attributes ||= ''
requested_attributes.split(',').each do |par|
- 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 build_table
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.build_table(klass, view, toptions={}, columns, filters, tabulatr_data_class, &block)
Function cbfn
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
var cbfn = function(event, isInView, visiblePartX, visiblePartY) {
if (isInView && visiblePartY !== 'top' && visiblePartY !== 'bottom') {
var tableId = $(event.currentTarget).data('table');
var table_obj;
for(var i = 0; i < tabulatr_tables.length; i++){
- 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 insertTabulatrData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
insertTabulatrData: function(response){
if (typeof response === "string")
response = JSON.parse(response);
var tableId = response.meta.table_id;
- 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 readParamsFromForm
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
readParamsFromForm: function(hash){
var form_array = $('.tabulatr_filter_form[data-table="'+ this.id +'"]')
.find('input:visible,select:visible,input[type=hidden]').serializeArray();
for(var i = 0; i < form_array.length; i++){
if(hash[form_array[i].name] !== undefined){
- 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"