Showing 12 of 20 total issues
Method apply_filters
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def apply_filters
@scope = filter_scope(@scope) do |s, f|
s = s.textual(f.title) if f.title.present?
s = s.where(id: @favourite_ids) if f.props.try(:include?, 'marked')
s = s.where(organizations: {id: f.organization_id}) if f.organization_id.present?
- 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 initEditor
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
window.initEditor = function(options) {
// Find the canvas element.
canvaso = document.getElementById('imageView');
if (!canvaso) {
alert('Error: I cannot find the canvas element!');
Method apply_filters
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def apply_filters
@scope = filter_scope(@scope) do |s, f|
s = s.textual(f.title) if f.title.present?
s = s.without_response if f.props.try(:include?, 'no_answer')
s = s.where(id: @favourite_ids) if f.props.try(:include?, 'marked')
- 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 rect
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
tools.rect = function () {
var tool = this;
this.started = false;
this.mousedown = function (ev) {
Function circle
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
tools.circle = function () {
var tool = this;
this.started = false;
this.mousedown = function (ev) {
Method apply_filters
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def apply_filters
@scope = filter_scope(@scope) do |s, f|
s = s.textual(f.title) if f.title.present?
s = s.where(id: @favourite_ids) if f.props.try(:include?, 'marked')
s = s.where(organizations: {id: f.organization_id}) if f.organization_id.present?
Function line
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
tools.line = function () {
var tool = this;
this.started = false;
this.mousedown = function (ev) {
Method sort_scope
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def sort_scope(scope)
if @column
if self.class.sortable_fields.include?(@column)
scope.order("#{@column} #{@direction}")
elsif block_given?
- 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 possible_causes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def possible_causes
if investigation
causes = investigation.documents
causes = causes.where(["documents.id NOT IN (?)", subtree_ids]) unless new_record?
causes.where(["documents.document_date IS NULL OR documents.document_date <= ?", document_date]) if document_date
- 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 too many return
statements within this function. Open
return;
Method sort_by
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sort_by(column)
return 'javascript:;' unless defined?(@sorter)
direction = @sorter.direction == 'asc' ? 'desc' : 'asc'
filter = @filter.try(:filterer).blank? ? nil : @filter.filterer.marshal_dump
- 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 allowed?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def allowed?
return true if @document.nil?
(snapshots_count >= 1 && attachements_count >= 1) ||
(snapshots_count == 0 && attachements_count > 1) ||
- 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"