Showing 175 of 175 total issues
Method render
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render(pdf, opts)
debug = false
if debug
pdf.stroke_axis
Method render_ics
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def render_ics(options, filename, cache_filename = nil)
@options = options
@options = {} if options.nil?
@options.reverse_merge!({
calendar_name: "Pennsic #{Pennsic.year} Master Schedule",
- 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
Class Instructable
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Instructable < ApplicationRecord
belongs_to :user
has_many :instances, -> { order('start_time, location') }, dependent: :destroy
has_many :changelogs, as: :target
accepts_nested_attributes_for :instances, allow_destroy: true
File changelog.rb
has 319 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Changelog < ApplicationRecord
belongs_to :user
belongs_to :target, polymorphic: true
default_scope { where(year: 2032) }
Method render_topic_list
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def render_topic_list(pdf, instructables)
pdf.move_down 8 unless pdf.cursor == pdf.bounds.top
pdf.font_size 14
pdf.text instructables.first.topic
pdf.font_size PDF_FONT_SIZE
- 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 render_pdf
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def render_pdf(filename, cache_filename = nil, user = nil)
pdf = Prawn::Document.new(page_size: 'LETTER', page_layout: :landscape,
:compress => true, :optimize_objects => true,
:info => {
:Title => "Pennsic University #{Pennsic.year} Timesheet for #{@date}, track #{@track}",
- 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 index
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def index
@allowed_tracks = current_user.allowed_tracks
@approved = get_param(:approved)
@date = get_param(: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
Method index
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
render_options = {}
respond_to do |format|
uncached = params[:uncached_for_tests].present?
Method render_pdf
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render_pdf(filename, cache_filename = nil, user = nil)
pdf = Prawn::Document.new(page_size: 'LETTER', page_layout: :landscape,
:compress => true, :optimize_objects => true,
:info => {
:Title => "Pennsic University #{Pennsic.year} Timesheet for #{@date}, track #{@track}",
Method show
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
# TODO: need to handle format here, and return an empty schedule for ICS requests
# where the user does exist, 404 where it does not, and redirect for html requests.
raise ActiveRecord::RecordNotFound.new('Not Found') unless @user
Method index
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@allowed_tracks = current_user.allowed_tracks
@approved = get_param(:approved)
@date = get_param(:date)
Consider simplifying this complex logical expression. Open
if change[:instances].present?
interesting = change[:instances].select { |i|
(i.action == 'update'
((i.current and i.current.start_time and i.current.start_time >= start_date and i.current.start_time <= end_date) or
(i.original and i.original.start_time and i.original.start_time >= start_date and i.original.start_time <= end_date))) or
Function formatDate
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
formatDate: function (date, format, language, type) {
if (date == null) {
return '';
}
var val;
Function updateNavArrows
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateNavArrows: function () {
var d = new Date(this.viewDate),
year = d.getUTCFullYear(),
month = d.getUTCMonth(),
day = d.getUTCDate(),
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (var i = 0, el, ev; i < this._events.length; i++) {
el = this._events[i][0];
ev = this._events[i][1];
el.off(ev);
}
- 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 86.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (var i = 0, el, ev; i < this._events.length; i++) {
el = this._events[i][0];
ev = this._events[i][1];
el.on(ev);
}
- 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 86.
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
Class Changelog
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Changelog < ApplicationRecord
belongs_to :user
belongs_to :target, polymorphic: true
default_scope { where(year: 2032) }
Similar blocks of code found in 2 locations. Consider refactoring. Open
format.xlsx {
if @user.schedule.nil? or @user.schedule.instructables.count == 0
raise ActiveRecord::RecordNotFound.new('Not Found')
end
- 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 92.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
format.csv {
if @user.schedule.nil? or @user.schedule.instructables.count == 0
raise ActiveRecord::RecordNotFound.new('Not Found')
end
- 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 92.
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 interesting_change
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.interesting_change(change, start_date, end_date)
action = change[:action]
ret = []
- 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"