Completed
Push — dev ( 73864e...ffd8f7 )
by Fike
38s
created

Variable   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 12.5 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
dl 4
loc 32
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A to_s() 0 3 1
A resolved? 0 3 1
A initialize() 0 4 1
A eql? 4 4 2
A hash() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
# frozen_string_literal: true
2
3
require_relative 'parameter'
4
require_relative 'any'
5
require_relative '../type'
6
require_relative '../exception/compliance_error'
7
8
module AMA
9
  module Entity
10
    class Mapper
11
      class Type
12
        # This class represents variable type - a type that is known only in
13
        # runtime when user specifies it
14
        class Variable < Type
15
          # @!attribute type
16
          #   @return [AMA::Entity::Mapper::Type]
17
          attr_reader :owner
18
          # @!attribute id
19
          #   @return [Symbol]
20
          attr_reader :id
21
22
          # @param [AMA::Entity::Mapper::Type] owner
23
          # @param [Symbol] id
24
          def initialize(owner, id)
25
            @owner = owner
26
            @id = id
27
          end
28
29
          def resolved?
30
            false
31
          end
32
33
          def to_s
34
            "Variable Type :#{id} (declared in #{owner})"
35
          end
36
37
          def hash
38
            @owner.hash ^ @id.hash
39
          end
40
41 View Code Duplication
          def eql?(other)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
42
            return false unless other.is_a?(self.class)
43
            id == other.id && owner == other.owner
44
          end
45
        end
46
      end
47
    end
48
  end
49
end
50