Engarce   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 27.59%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 49
ccs 8
cts 29
cp 0.2759
rs 10
wmc 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A disponibles() 0 11 1
A big_img() 0 3 1
A initialize() 0 5 1
A img_path() 0 3 1
A item() 0 3 1
B bonificador() 0 13 5
1
# Engarce = objetos engarzables: gemas, joyas y runas
2 1
class Engarce < Hash
3 1
  attr_accessor :id, :name, :fits
4
5 1
  def initialize(args)
6
    args.each do |k, v|
7
      instance_variable_set("@#{k}".to_sym, v) unless v.nil?
8
    end
9
  end
10
11 1
  def item
12
    self.class.to_s.downcase
13
  end
14
15 1
  def img_path
16
    "'../../images/treasures/#{item}s/#{name}.png'"
17
  end
18
19 1
  def big_img
20
    "'../../images/items/#{item}s/#{name}.png'"
21
  end
22
23 1
  def bonificador(item)
0 ignored issues
show
Coding Style introduced by
The Assignment, Branch, Condition size for bonificador is considered too high. [25.63/15]. The ABC size is based on assignments, branches (method calls), and conditions.
Loading history...
Coding Style introduced by
The method bonificador seems to be too complex. Perceived cyclomatic complexity is 10 with a maxiumum of 6 permitted.
Loading history...
Coding Style introduced by
This method is 11 lines long. Your coding style permits a maximum length of 10.
Loading history...
Complexity Coding Style introduced by
The method bonificador seems to be too complex. Perceived complexity is 11 with a maxiumum of 7 permitted.
Loading history...
24
    if item.fits == 'arma'
25
      fits[item.categoria] || fits['arma'] || 'Armas sin implementar'
26
    elsif item.fits == 'armadura'
27
      fits[item.categoria] || fits['pecho'] || 'Armaduras sin implementar'
28
    elsif fits[item.fits]
29
      fits[item.fits]
30
    elsif item.class == Proteccion
31
      fits['armadura'] || 'Sin bonificador'
32
    else
33
      'Sin efecto'
34
    end
35
  end
36
37
  # returns from heros.tesoro, the list of (maybe repeated)
38
  # ids of the heros with self.id gem/runa/joya available
39 1
  def disponibles
0 ignored issues
show
Coding Style introduced by
The Assignment, Branch, Condition size for disponibles is considered too high. [16.31/15]. The ABC size is based on assignments, branches (method calls), and conditions.
Loading history...
40
    total = []
41
    heros.each do |h|
42
      next unless h.tesoro
43
      next unless h.tesoro[item + 's']
44
      h.tesoro[item + 's'].each do |e|
45
        (total << h.id) if e == id
46
      end
47
    end
48
    total
49
  end
50
end
51