app/assets/javascripts/tab_lazy_load.js
Function tab_on_click
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function tab_on_click(scale_title, resource_type, resource_ids, actions_partial_disable){
var click_tab = document.getElementsByClassName(scale_title + '_' + resource_type)[0];
click_tab.onclick = function(){
deactivate_previous_tab(this);
click_tab.parentElement.className = 'tabberactive';
Function onclick
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
click_tab.onclick = function(){
deactivate_previous_tab(this);
click_tab.parentElement.className = 'tabberactive';
//if the content of the click_tab is already loaded, just show it, otherwise call ajax to get the content
Function deactivate_previous_tab
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
function deactivate_previous_tab(tab_element){
var previous_active_tab = tab_element.up("ul.tabbernav").getElementsByClassName('tabberactive')[0];
previous_active_tab.className = '';
//Then hide the content of the tab
var scale_and_type = previous_active_tab.childNodes[0].className;
- 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"