Showing 182 of 182 total issues
Method convert_units
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convert_units(new_article = shared_article)
return unless unit != new_article.unit
return false if new_article.unit.include?(',')
# legacy, used by foodcoops in Germany
Method sync_from_file
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sync_from_file(file, options = {})
all_order_numbers = []
updated_article_pairs = []
outlisted_articles = []
new_articles = []
Function reset
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
window.List.prototype.plugins.reset = function(locals, options) {
var list = this;
var init = {
start: function(options) {
Method ordergroup
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ordergroup
@user = @current_user
@ordergroup = @user.ordergroup
if @ordergroup.nil?
- 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 update_synchronized
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_synchronized
@outlisted_articles = Article.find(params[:outlisted_articles].try(:keys) || [])
@updated_articles = Article.find(params[:articles].try(:keys) || [])
@updated_articles.map { |a| a.assign_attributes(params[:articles][a.id.to_s]) }
@new_articles = (params[:new_articles] || []).map { |a| @supplier.articles.build(a) }
- 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 init_dates
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def init_dates
self.starts ||= Time.now
if FoodsoftConfig[:order_schedule]
# try to be smart when picking a reference day
last = begin
- 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 parse
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.parse(file, options = {})
SpreadsheetFile.parse file, options do |row, row_index|
next if row[2].blank?
article = { order_number: row[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"
Further reading
Method sync_all
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def sync_all
updated_article_pairs = []
outlisted_articles = []
new_articles = []
existing_articles = Set.new
- 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 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
sort = if params['sort']
case params['sort']
when 'name' then 'articles.name'
when 'unit' then 'articles.unit'
Method received
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def received(data)
mail = Mail.new data
mail_part = get_mail_part(mail)
raise 'No valid content could be found' if mail_part.nil?
Method sum
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sum(type = :gross)
total = 0
if %i[net gross fc].include?(type)
for oa in order_articles.ordered.includes(:article, :article_price)
quantity = oa.units * oa.price.unit_quantity
Method index
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
sort = if params['sort']
case params['sort']
when 'date' then 'date'
when 'amount' then 'amount'
Method index
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
sort = if params['sort']
case params['sort']
when 'date' then 'created_on'
when 'note' then 'note'
Method import
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import
@bank_account = BankAccount.find(params[:id])
importer = @bank_account.find_connector
if importer
Method unequal_attributes
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def unequal_attributes(new_article, options = {})
# try to convert different units when desired
if options[:convert_units] == false
new_price = nil
new_unit_quantity = nil
Similar blocks of code found in 2 locations. Consider refactoring. Open
$(document).on('click', 'a[data-remove-this]', function() {
$($(this).data('remove-this')).remove();
return false;
});
- 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 55.
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
Consider simplifying this complex logical expression. Open
unless (delta_q == 0 && delta_t >= 0) ||
(delta_mis < 0 && delta_box >= 0 && delta_t >= 0) ||
(delta_q > 0 && delta_q == -delta_t)
raise ActiveRecord::RecordNotSaved.new("Change not acceptable in boxfill phase for '#{article.name}', sorry.",
self)
Similar blocks of code found in 2 locations. Consider refactoring. Open
$(document).on('click', 'a[data-toggle-this]', function() {
$($(this).data('toggle-this')).toggle();
return false;
});
- 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 55.
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
Function addData
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
function addData(orderArticleId, itemPrice, itemUnit, itemSubtotal, itemQuantityOthers, itemToleranceOthers, allocated, available) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
def navigation(primary, context)
return unless FoodsoftPolls.enabled?
return if primary[:foodcoop].nil?
sub_nav = primary[:foodcoop].sub_navigation
- 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 47.
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