pasosdeJesus/heb412_gen

View on GitHub
app/helpers/heb412_gen/plantilla_helper.rb

Summary

Maintainability
B
6 hrs
Test Coverage
C
76%

Method campos_vista_formulario has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def campos_vista_formulario(v, formularios, agrega_ult_ed)
      ab = ::Ability.new
      col = if v.nil? || ab.campos_plantillas[v].nil?
        [["", ""]]
      else
Severity: Minor
Found in app/helpers/heb412_gen/plantilla_helper.rb - About 1 hr 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 compara_columnas has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def compara_columnas(col1, col2)
      if col1.length < col2.length
        return -1
      end
      if col2.length < col1.length
Severity: Minor
Found in app/helpers/heb412_gen/plantilla_helper.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 antcol has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def antcol(col)
      if col == ""
        raise "No puede calcular antcol(nil)"
      end

Severity: Minor
Found in app/helpers/heb412_gen/plantilla_helper.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 sigcol has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def sigcol(col)
      res = ""
      i = col.length - 1
      lleva = 1
      while i >= 0
Severity: Minor
Found in app/helpers/heb412_gen/plantilla_helper.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

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

    def elimina_columna(plantillahcm_id, id)
      pore = Heb412Gen::Campoplantillahcm
        .where(plantillahcm_id: plantillahcm_id).where(id: id).take
      unless pore
        raise "No se encontró columna con id #{id} en "\
Severity: Minor
Found in app/helpers/heb412_gen/plantilla_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

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

        elsif resta == 1 && col[i] == "A"
          res = "Z" + res
          resta = 1
        elsif resta == 1
          c0 = col[i].ord - 1
Severity: Minor
Found in app/helpers/heb412_gen/plantilla_helper.rb and 1 other location - About 50 mins to fix
app/helpers/heb412_gen/plantilla_helper.rb on lines 49..58

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

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

        if lleva == 1 && col[i] == "Z"
          res = "A" + res
          lleva = 1
        elsif lleva == 1
          c0 = col[i].ord + 1
Severity: Minor
Found in app/helpers/heb412_gen/plantilla_helper.rb and 1 other location - About 50 mins to fix
app/helpers/heb412_gen/plantilla_helper.rb on lines 83..92

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

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

      cols.each do |icol|
        comp = compara_columnas(icol[1], col)
        next unless comp >= 0

        c = Heb412Gen::Campoplantillahcm.find(icol[0])
Severity: Minor
Found in app/helpers/heb412_gen/plantilla_helper.rb and 1 other location - About 35 mins to fix
app/helpers/heb412_gen/plantilla_helper.rb on lines 177..184

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

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

      cols.each do |icol|
        comp = compara_columnas(icol[1], col)
        next unless comp > 0

        # Mueve cada una de las que esté a la derecha de la col-esima
Severity: Minor
Found in app/helpers/heb412_gen/plantilla_helper.rb and 1 other location - About 35 mins to fix
app/helpers/heb412_gen/plantilla_helper.rb on lines 138..144

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

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

There are no issues that match your filters.

Category
Status