tbpgr/tbpgr_utils

View on GitHub

Showing 37 of 37 total issues

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

  def self.to_binary_table(from = 1, to = 10)
    ret = []
    size = to.to_s(2).size - 1
    pad = (size / 8 + 1) * 8
    ret << '|10digit|2digit|'
Severity: Major
Found in lib/open_classes/numeric/to_binary_table.rb and 1 other location - About 1 hr to fix
lib/open_classes/numeric/to_hex_table.rb on lines 19..26

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

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 self.to_hex_table(from = 1, to = 10)
    ret = []
    size = to.to_s(16).size - 1
    pad = (size / 4 + 1) * 4
    ret << '|10digit|16digit|'
Severity: Major
Found in lib/open_classes/numeric/to_hex_table.rb and 1 other location - About 1 hr to fix
lib/open_classes/numeric/to_binary_table.rb on lines 20..27

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

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 self.to_binary_html_table(from = 1, to = 10)
    ret = []
    size = to.to_s(2).size - 1
    pad = (size / 8 + 1) * 8
    ret << "<table>\n  <tr>\n    <th>10digit</th>\n    <th>2digit</th>\n  </tr>"
Severity: Major
Found in lib/open_classes/numeric/to_binary_html_table.rb and 1 other location - About 1 hr to fix
lib/open_classes/numeric/to_hex_html_table.rb on lines 30..36

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

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 self.to_hex_html_table(from = 1, to = 10)
    ret = []
    size = to.to_s(16).size - 1
    pad = (size / 4 + 1) * 4
    ret << "<table>\n  <tr>\n    <th>10digit</th>\n    <th>16digit</th>\n  </tr>"
Severity: Major
Found in lib/open_classes/numeric/to_hex_html_table.rb and 1 other location - About 1 hr to fix
lib/open_classes/numeric/to_binary_html_table.rb on lines 30..37

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

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 AttrEnumerable
  private
    def last_attr(attribute, method_name, *args, &block)
      col = collection
      return [] if col.empty?
Severity: Minor
Found in lib/attr_enumerable/last_attr.rb and 1 other location - About 1 hr to fix
lib/attr_enumerable/first_attr.rb on lines 5..14

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

Further Reading

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

module AttrEnumerable
  private
    def first_attr(attribute, method_name, *args, &block)
      col = collection
      return [] if col.empty?
Severity: Minor
Found in lib/attr_enumerable/first_attr.rb and 1 other location - About 1 hr to fix
lib/attr_enumerable/last_attr.rb on lines 5..14

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

Further Reading

Method get_brothers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_brothers(person)
      ret = []
      tmp_family = family.dup
      person.parent_ids.each do |parent_id|
        tmp_family.each do |v|
Severity: Minor
Found in lib/familyable/familynize.rb - About 55 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 setting_variables_code has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def setting_variables_code(variables)
    fail TypeError, "invalid type #{variables.class}. you have to use Array" unless variables.is_a? Array
    variables.reduce([]) do |ret, variable|
      fail TypeError, "invalid type #{variable.class}. you have to use Hash" unless variable.is_a? Hash
      fail TypeError, 'invalid hash. you have to set Hash[:name]' if variable[:name].nil?
Severity: Minor
Found in lib/eval_helper/set_variables_code.rb - About 55 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 to_heading has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def to_heading
      self_chars = chars
      level, index, word_ret, ret = 0, 0, [], []
      self_chars.each_with_index do |v, index|
        key_word = v.in? %w(> + ^)
Severity: Minor
Found in lib/open_classes/string/heading_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 must_impl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def must_impl(*methods)
      return if methods.nil?
      fail TypeError, "invalid args type #{methods.class}. you must use Array or Symbol" unless methods.class.any_of? Array, Symbol
      methods = (methods.class.is_a? Symbol) ? [methods] : methods
      methods.each do |method_name|
Severity: Minor
Found in lib/template_methodable.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 together_fill has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def together_fill(fill_value = nil, &block)
    if_not_contain_array_rails_type_error
    if block
      fill_value = 0 if fill_value.nil?
      first.each_with_index do |i_v, i|
Severity: Minor
Found in lib/open_classes/array/together_fill.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 start_match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def start_match(proc)
    @tournament.reverse_each.with_index do |outer, outer_index|
      outer.reverse_each.with_index do |inner, inner_index|
        next if inner_index.odd?
        next if inner_index == outer.size - 1
Severity: Minor
Found in lib/simple_tournament.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

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

    (from..to).each { |i|ret << "|#{i}|#{i.to_s(2).rjust(binary_pad, '0')}|#{i.to_s(8).rjust(oct_size, '0')}|#{i.to_s(16).rjust(hex_pad, '0')}|" }
Severity: Minor
Found in lib/open_classes/numeric/to_digit_table.rb and 1 other location - About 35 mins to fix
lib/open_classes/numeric/to_digit_html_table.rb on lines 44..44

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

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

    (from..to).each { |i|ret << "  <tr>\n    <td>#{i}</td>\n    <td>#{i.to_s(2).rjust(binary_pad, '0')}</td>\n    <td>#{i.to_s(8).rjust(oct_size, '0')}</td>\n    <td>#{i.to_s(16).rjust(hex_pad, '0')}</td>\n  </tr>" }
Severity: Minor
Found in lib/open_classes/numeric/to_digit_html_table.rb and 1 other location - About 35 mins to fix
lib/open_classes/numeric/to_digit_table.rb on lines 27..27

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

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

  def to_html_table(options = { no_header: false })
    options[:no_header] = false if options[:no_header].nil?
    cnt = options[:no_header] ? 1 : 0
    ret = reduce(['<table>']) do |rets, lines|
      ret = lines.reduce([]) do |ret, column|
Severity: Minor
Found in lib/open_classes/array/to_html_table.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

  def self.ul(list)
    return list unless list.is_a?(Array)
    return '' if list.empty?
    list.reduce([]) do |ret, elm|
      elm = '' if elm.nil?
Severity: Minor
Found in lib/markdown/ul.rb and 1 other location - About 35 mins to fix
lib/markdown/ol.rb on lines 35..42

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

Method first_attr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def first_attr(attribute, method_name, *args, &block)
      col = collection
      return [] if col.empty?
      first_size = args.size == 0 ? nil : Integer(args.first)
      fail ArgumentError, "invalid attribute #{attribute}" unless include_attr?(col.first, attribute)
Severity: Minor
Found in lib/attr_enumerable/first_attr.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 last_attr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def last_attr(attribute, method_name, *args, &block)
      col = collection
      return [] if col.empty?
      last_size = args.size == 0 ? nil : Integer(args.last)
      fail ArgumentError, "invalid attribute #{attribute}" unless include_attr?(col.last, attribute)
Severity: Minor
Found in lib/attr_enumerable/last_attr.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

  def self.ol(list)
    return list unless list.is_a?(Array)
    return '' if list.empty?
    list.reduce([]) do |ret, elm|
      elm = '' if elm.nil?
Severity: Minor
Found in lib/markdown/ol.rb and 1 other location - About 35 mins to fix
lib/markdown/ul.rb on lines 35..42

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

class Array
  include TogetherHelper

  # Arrays bulk first.
  #
Severity: Minor
Found in lib/open_classes/array/together_first.rb and 1 other location - About 25 mins to fix
lib/open_classes/array/together_last.rb on lines 7..40

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

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

Severity
Category
Status
Source
Language