dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation   A
last analyzed

Complexity

Total Complexity 36

Size/Duplication

Total Lines 115
Duplicated Lines 97.39 %

Importance

Changes 0
Metric Value
wmc 36
eloc 81
dl 112
loc 115
rs 9.52
c 0
b 0
f 0

26 Methods

Rating   Name   Duplication   Size   Complexity  
A GridLocation.__init__() 11 11 1
A GridLocation.__str__() 2 2 1
A GridLocation.getSiteId() 2 2 1
A GridLocation.getCrsWKT() 2 2 1
A GridLocation.setTimeZone() 2 2 1
A GridLocation.getIdentifier() 2 2 1
A GridLocation.setExtent() 2 2 1
B GridLocation.isValid() 8 8 6
A GridLocation.setCrsWKT() 2 2 1
A GridLocation.setSiteId() 2 2 1
A GridLocation.setGeometry() 2 2 1
A GridLocation.__ne__() 2 2 1
A GridLocation.setOrigin() 2 2 1
A GridLocation.getTimeZone() 2 2 1
A GridLocation.getProjection() 2 2 1
A GridLocation.getExtent() 2 2 1
A GridLocation.setNx() 2 2 1
A GridLocation.getOrigin() 2 2 1
A GridLocation.setProjection() 2 2 1
A GridLocation.getNy() 2 2 1
B GridLocation.__eq__() 16 16 6
A GridLocation.setNy() 2 2 1
A GridLocation.__repr__() 6 6 1
A GridLocation.getNx() 2 2 1
A GridLocation.getGeometry() 2 2 1
A GridLocation.setIdentifier() 2 2 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
2
3 View Code Duplication
class GridLocation(object):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4
5
    def __init__(self):
6
        self.siteId = None
7
        self.nx = None
8
        self.ny = None
9
        self.timeZone = None
10
        self.projection = None
11
        self.origin = None
12
        self.extent = None
13
        self.geometry = None
14
        self.crsWKT = None
15
        self.identifier = None
16
17
    def __str__(self):
18
        return self.__repr__()
19
20
    def __repr__(self):
21
        # TODO: Handle geometry in dynamicserialize
22
        # ,loc=" + this.geometry.getGeometryType()
23
        s = "[SiteID =" + self.siteId + ",ProjID=" + self.projection.getProjectionID() +\
24
            ",gridSize=(" + str(self.nx) + ',' + str(self.ny) + ")]"
25
        return s
26
27
    def __eq__(self, other):
28
        if not isinstance(other, GridLocation):
29
            return False
30
        if self.siteId != other.siteId:
31
            return False
32
        if self.crsWKT != other.crsWKT:
33
            return False
34
        # FIXME: Geometry/Polygon objects don't really work in dynamicserialize
35
        # commenting out this check unless it causes problems
36
#        if self.geometry != other.geometry:
37
#            return False
38
        if self.nx != other.nx:
39
            return False
40
        if self.ny != other.ny:
41
            return False
42
        return True
43
44
    def __ne__(self, other):
45
        return not self.__eq__(other)
46
47
    def getSiteId(self):
48
        return self.siteId
49
50
    def setSiteId(self, siteId):
51
        self.siteId = siteId
52
53
    def getNx(self):
54
        return self.nx
55
56
    def setNx(self, nx):
57
        self.nx = nx
58
59
    def getNy(self):
60
        return self.ny
61
62
    def setNy(self, ny):
63
        self.ny = ny
64
65
    def getTimeZone(self):
66
        return self.timeZone
67
68
    def setTimeZone(self, timeZone):
69
        self.timeZone = timeZone
70
71
    def getProjection(self):
72
        return self.projection
73
74
    def setProjection(self, projection):
75
        self.projection = projection
76
77
    def getOrigin(self):
78
        return self.origin
79
80
    def setOrigin(self, origin):
81
        self.origin = origin
82
83
    def getExtent(self):
84
        return self.extent
85
86
    def setExtent(self, extent):
87
        self.extent = extent
88
89
    def getGeometry(self):
90
        return self.geometry
91
92
    def setGeometry(self, geometry):
93
        self.geometry = geometry
94
95
    def getCrsWKT(self):
96
        return self.crsWKT
97
98
    def setCrsWKT(self, crsWKT):
99
        self.crsWKT = crsWKT
100
101
    def getIdentifier(self):
102
        return self.identifier
103
104
    def setIdentifier(self, identifier):
105
        self.identifier = identifier
106
107
    def isValid(self):
108
        if self.projection is None:
109
            return False
110
        if self.nx < 2 or self.ny < 2:
111
            return False
112
        if self.origin is None or self.extent is None:
113
            return False
114
        return True
115