Showing 628 of 628 total issues
Function bpMinVersion
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function bpMinVersion(min, actual) {
function parseVersionString (str) {
if (typeof(str) != 'string') { return false; }
var x = str.split('.');
var maj = parseInt(x[0]) || 0;
- 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 response_errors
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def response_errors(error_struct)
error_struct = parse_response_body(error_struct)
errors = {error: "There was an error, please try again"}
return errors unless error_struct
return errors unless error_struct.respond_to?(:errors)
- 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
Avoid deeply nested control flow statements. Open
if (params.output_type == 2) {
ontologyLinkStyle = 'style="color: ' + rec.colors[j] + '"';
}
Method get_ontologies_data
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_ontologies_data(ontologies = nil)
ontologies ||= LinkedData::Client::Models::Ontology.all(include: "acronym,name")
@onts_for_select = []
@onts_acronym_map = {}
@onts_uri2acronym_map = {}
- 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
Avoid deeply nested control flow statements. Open
if ($this.is(':checked')) {
// Deselect all the rest checkboxes
for (var j = 0; j < data.length; j++) {
if (j!=$rowNumber) {
$("#chk" + j).prop('checked', false);
Function bindRequestTermSaveClick
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function bindRequestTermSaveClick() {
var success = "";
var error = "";
var user = jQuery(document).data().bp.user;
var ontology_id = jQuery(document).data().bp.ont_viewer.ontology_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
Method status_link
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def status_link(submission, latest = false, target = '')
version_text = submission.version.nil? || submission.version.length == 0 ? 'unknown' : submission.version
status_text = " <span class='ontology_submission_status'>" + submission_status2string(submission) + '</span>'
if submission.ontology.summaryOnly || latest == false
version_link = version_text
- 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 create
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create
u = LinkedData::Client::Models::User.find(params[:user_id])
ont = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id]).first
# Is this request to add or remove a subscription?
- 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 custom_ontologies
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def custom_ontologies
@user = LinkedData::Client::Models::User.find(params[:id])
@user = LinkedData::Client::Models::User.find_by_username(params[:id]).first if @user.nil?
custom_ontologies = params[:ontology] ? params[:ontology][:ontologyId] : []
- 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 authorize_owner
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def authorize_owner(id=nil)
if id.nil?
id = params[:id].to_i
end
- 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
Avoid deeply nested control flow statements. Open
if (matchSubset(x0, q)) {
csub[csub.length] = x;
}
Avoid deeply nested control flow statements. Open
for (var j = 0; j < data[i].coverageResult.annotations.length; j++) {
terms += ('<a target="_blank" href=' + data[i].coverageResult.annotations[j].annotatedClass.links.ui + '>' + data[i].coverageResult.annotations[j].text + '</a>, ');
}
Method struct_to_hash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def struct_to_hash(struct)
hash = {}
struct.members.each do |attr|
next if [:links, :context].include?(attr)
if struct[attr].is_a?(Struct) || struct[attr].is_a?(OpenStruct)
- 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 displayUsers
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function displayUsers(data) {
let ontTable = null;
let allRows
if (jQuery.fn.dataTable.isDataTable('#adminUsers')) {
ontTable = jQuery('#adminUsers').DataTable();
- 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 display_annotations
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function display_annotations(data, params) {
"use strict";
var annotations = data.annotations;
var all_rows = [];
if (params.raw !== undefined && params.raw === true) {
- 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 update_annotations_table
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function update_annotations_table(rowsArray) {
"use strict";
var ontologies = {},
classes = {},
match_types = {},
- 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 bp_internal_formComplete_formatItem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function bp_internal_formComplete_formatItem(row) {
var input = this.extraParams.input;
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\
var keywords = jQuery(input).val().replace(specials, "\\$&").split(' ').join('|');
var regex = new RegExp( '(' + keywords + ')', 'gi' );
- 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 getHighlightedTerms
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
rec.getHighlightedTerms = function(data, rowNumber) {
var inputText = document.getElementById("inputText").value;
var newText = '';
var lastPosition = 0;
var ontologyIds = [ ];
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
lunr.TokenStore = function () {
this.root = { docs: {} }
this.length = 0
}
- 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 50.
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
Method destroy
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def destroy
note_ids = params[:noteids].kind_of?(String) ? params[:noteids].split(',') : params[:noteids]
ontology = DataAccess.getOntology(params[:ontologyid])
- 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"