jcottobboni/inventorymaster

View on GitHub

Showing 17 of 17 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def out_stock_list
        if params[:location].blank? and params[:area].blank? and params[:manufacturer].blank?
        @products = Product.where(' ammount = 0')
      elsif params[:location].blank? and params[:area].blank?
        @products = Product.where(' ammount = 0 and manufacturer_id=?',params[:manufacturer])
Severity: Major
Found in app/controllers/inventorymaster/reports_controller.rb and 1 other location - About 4 hrs to fix
app/controllers/inventorymaster/reports_controller.rb on lines 58..83

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 158.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      def low_stock_list
        if params[:location].blank? and params[:area].blank? and params[:manufacturer].blank?
        @products = Product.where(' ammount <= minimum_stock_count')
      elsif params[:location].blank? and params[:area].blank?
        @products = Product.where(' ammount <= minimum_stock_count and manufacturer_id=?',params[:manufacturer])
Severity: Major
Found in app/controllers/inventorymaster/reports_controller.rb and 1 other location - About 4 hrs to fix
app/controllers/inventorymaster/reports_controller.rb on lines 90..115

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 158.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module Inventorymaster
  class AreasController < ApplicationController
    before_action :set_area, only: [:show, :edit, :update, :destroy]

    # GET /areas
Severity: Major
Found in app/controllers/inventorymaster/areas_controller.rb and 1 other location - About 2 hrs to fix
app/controllers/inventorymaster/transaction_types_controller.rb on lines 3..59

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 82.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module Inventorymaster
  class TransactionTypesController < ApplicationController
    before_action :set_transaction_type, only: [:show, :edit, :update, :destroy]

    # GET /transaction_types
app/controllers/inventorymaster/areas_controller.rb on lines 3..59

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 82.

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

Further Reading

Function addFields has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    addFields: function(e) {
      // Setup
      var link      = e.currentTarget;
      var assoc     = $(link).data('association');                // Name of child
      var blueprint = $('#' + $(link).data('blueprint-id'));
Severity: Minor
Found in public/javascripts/nested_form.js - About 1 hr to fix

    Method out_stock_list has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def out_stock_list
            if params[:location].blank? and params[:area].blank? and params[:manufacturer].blank?
            @products = Product.where(' ammount = 0')
          elsif params[:location].blank? and params[:area].blank?
            @products = Product.where(' ammount = 0 and manufacturer_id=?',params[:manufacturer])
    Severity: Minor
    Found in app/controllers/inventorymaster/reports_controller.rb - About 1 hr to fix

      Method low_stock_list has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def low_stock_list
              if params[:location].blank? and params[:area].blank? and params[:manufacturer].blank?
              @products = Product.where(' ammount <= minimum_stock_count')
            elsif params[:location].blank? and params[:area].blank?
              @products = Product.where(' ammount <= minimum_stock_count and manufacturer_id=?',params[:manufacturer])
      Severity: Minor
      Found in app/controllers/inventorymaster/reports_controller.rb - About 1 hr to fix

        Method create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def create
              @transaction = Transaction.new(transaction_params)
              @product = Product.find(@transaction.product_id)
        
              if @transaction.kind =="Entrada" && @product.ammount!= nil
        Severity: Minor
        Found in app/controllers/inventorymaster/transactions_controller.rb - About 45 mins to fix

        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 current_stock_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def current_stock_list
               if params[:location].blank? and params[:area].blank? and params[:manufacturer].blank?
                @products = Product.all
              elsif params[:location].blank? and params[:area].blank?
                @products = Product.where(:manufacturer_id=>params[:manufacturer])
        Severity: Minor
        Found in app/controllers/inventorymaster/reports_controller.rb - About 35 mins to fix

        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

          module ProductsHelper
             def average_cost(unit_cost,ammount)
                        if unit_cost == nil
                            if @cost || @average ==0
                                return 0
        Severity: Minor
        Found in app/helpers/inventorymaster/products_helper.rb and 1 other location - About 35 mins to fix
        app/helpers/inventorymaster/reports_helper.rb on lines 2..13

        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 34.

        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

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          module ReportsHelper
             def average_cost(unit_cost,ammount)
                        if unit_cost == nil
                            if @cost || @average ==0
                                return 0
        Severity: Minor
        Found in app/helpers/inventorymaster/reports_helper.rb and 1 other location - About 35 mins to fix
        app/helpers/inventorymaster/products_helper.rb on lines 2..13

        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 34.

        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

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    content = content.replace(
                      new RegExp('(\\[' + parentNames[i] + '\\])\\[.+?\\]', 'g'),
                      '$1[' + parentIds[i] + ']');
        Severity: Minor
        Found in public/javascripts/nested_form.js and 1 other location - About 30 mins to fix
        public/javascripts/nested_form.js on lines 29..31

        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 45.

        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

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    content = content.replace(
                      new RegExp('(_' + parentNames[i] + ')_.+?_', 'g'),
                      '$1_' + parentIds[i] + '_');
        Severity: Minor
        Found in public/javascripts/nested_form.js and 1 other location - About 30 mins to fix
        public/javascripts/nested_form.js on lines 33..35

        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 45.

        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

        Further Reading

        Method average_cost has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

             def average_cost(unit_cost,ammount)
                        if unit_cost == nil
                            if @cost || @average ==0
                                return 0
                            else
        Severity: Minor
        Found in app/helpers/inventorymaster/products_helper.rb - About 25 mins to fix

        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 low_stock_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def low_stock_list
                if params[:location].blank? and params[:area].blank? and params[:manufacturer].blank?
                @products = Product.where(' ammount <= minimum_stock_count')
              elsif params[:location].blank? and params[:area].blank?
                @products = Product.where(' ammount <= minimum_stock_count and manufacturer_id=?',params[:manufacturer])
        Severity: Minor
        Found in app/controllers/inventorymaster/reports_controller.rb - About 25 mins to fix

        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 average_cost has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

             def average_cost(unit_cost,ammount)
                        if unit_cost == nil
                            if @cost || @average ==0
                                return 0
                            else
        Severity: Minor
        Found in app/helpers/inventorymaster/reports_helper.rb - About 25 mins to fix

        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 out_stock_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def out_stock_list
                if params[:location].blank? and params[:area].blank? and params[:manufacturer].blank?
                @products = Product.where(' ammount = 0')
              elsif params[:location].blank? and params[:area].blank?
                @products = Product.where(' ammount = 0 and manufacturer_id=?',params[:manufacturer])
        Severity: Minor
        Found in app/controllers/inventorymaster/reports_controller.rb - About 25 mins to fix

        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

        Severity
        Category
        Status
        Source
        Language