Skip to content

Commit e73bc24

Browse files
committed
Revert "more linting"
This reverts commit 09671b2
1 parent aaf495d commit e73bc24

36 files changed

Lines changed: 294 additions & 313 deletions

pkg/utils/xml.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,35 @@ type XMLAttribute []xml.Attr
99

1010
// StripDuplicateAttr removes the duplicate Attributes from a []Attribute
1111
func StripDuplicateAttr(attr []xml.Attr) []xml.Attr {
12-
attributeMap := make(map[xml.Name]string)
12+
attributemap := make(map[xml.Name]string)
1313
for _, a := range attr {
14-
attributeMap[xml.Name{Space: a.Name.Space, Local: a.Name.Local}] = a.Value
14+
attributemap[xml.Name{Space: a.Name.Space, Local: a.Name.Local}] = a.Value
1515
}
1616

1717
var strippedAttr []xml.Attr
18-
for k, v := range attributeMap {
18+
for k, v := range attributemap {
1919
strippedAttr = append(strippedAttr, xml.Attr{Name: k, Value: v})
2020
}
2121
return strippedAttr
2222
}
2323

2424
// UnmarshalXML func for the XMLAttr struct
2525
func (xmlattr *XMLAttribute) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
26-
var newAttributes XMLAttribute
26+
var newattributes XMLAttribute
2727
for _, attr := range start.Attr {
28-
newAttributes = append(newAttributes, xml.Attr{Name: attr.Name, Value: attr.Value})
28+
switch attr.Name.Local {
29+
default:
30+
newattributes = append(newattributes, xml.Attr{Name: attr.Name, Value: attr.Value})
31+
}
2932
}
30-
*xmlattr = newAttributes
33+
*xmlattr = newattributes
3134

3235
for {
3336
// if it got this far the XML is 'valid' and the xmlattr are set
3437
// so we ignore the err
3538
token, _ := d.Token()
36-
37-
if el, ok := token.(xml.EndElement); ok {
39+
switch el := token.(type) {
40+
case xml.EndElement:
3841
if el == start.End() {
3942
return nil
4043
}

pkg/wfs200/capabilities.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package wfs200
22

33
import (
44
"encoding/xml"
5-
65
"github.com/pdok/ogc-specifications/pkg/wsc110"
76
)
87

@@ -165,7 +164,7 @@ type MetadataHref struct {
165164
// FilterCapabilities struct for the WFS 2.0.0
166165
type FilterCapabilities struct {
167166
Conformance Conformance `xml:"fes:Conformance" yaml:"conformance"`
168-
IDCapabilities IDCapabilities `xml:"fes:Id_Capabilities" yaml:"idCapabilities"`
167+
IDCapabilities IdCapabilities `xml:"fes:Id_Capabilities" yaml:"idCapabilities"`
169168
ScalarCapabilities ScalarCapabilities `xml:"fes:Scalar_Capabilities" yaml:"scalarCapabilities"`
170169
SpatialCapabilities SpatialCapabilities `xml:"fes:Spatial_Capabilities" yaml:"spatialCapabilities"`
171170
// NO TemporalCapabilities!!!
@@ -177,8 +176,8 @@ type Conformance struct {
177176
Constraint []ValueConstraint `xml:"fes:Constraint" yaml:"constraint"`
178177
}
179178

180-
// IDCapabilities struct for the WFS 2.0.0
181-
type IDCapabilities struct {
179+
// IdCapabilities struct for the WFS 2.0.0
180+
type IdCapabilities struct {
182181
ResourceIdentifier ResourceIdentifier `xml:"fes:ResourceIdentifier" yaml:"resourceIdentifier"`
183182
}
184183

pkg/wfs200/crs_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ func TestMarshalYAMLCrs(t *testing.T) {
6868
}
6969
for k, test := range tests {
7070
yamlCRS, err := yaml.Marshal(test.CRS)
71-
7271
if err != nil {
7372
t.Errorf("test: %d, yaml.Marshal failed with '%s'\n", k, err)
74-
} else if stringCRS := string(yamlCRS); stringCRS != test.expectedYAML {
75-
t.Errorf("test: %d, expected: %v+,\n got: %v+", k, test.expectedYAML, stringCRS)
73+
} else {
74+
stringCRS := string(yamlCRS)
75+
if stringCRS != test.expectedYAML {
76+
t.Errorf("test: %d, expected: %v+,\n got: %v+", k, test.expectedYAML, stringCRS)
77+
}
7678
}
7779
}
7880
}

pkg/wfs200/describefeaturetype_request_pv.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
"github.com/pdok/ogc-specifications/pkg/wsc110"
88
)
99

10-
//nolint:govet
1110
type describeFeatureTypeRequestParameterValue struct {
1211
service string `yaml:"service" json:"service"`
1312
baseParameterValueRequest
13+
1414
typeName *string `yaml:"typeName" json:"typeName"` // [0..*]
1515
outputFormat *string `yaml:"outputFormat" json:"outputFormat"` // default: "text/xml; subtype=gml/3.2"
1616
}
@@ -45,12 +45,13 @@ func (dpv *describeFeatureTypeRequestParameterValue) parseQueryParameters(query
4545
return nil
4646
}
4747

48-
func (dpv *describeFeatureTypeRequestParameterValue) parseDescribeFeatureTypeRequest(dft DescribeFeatureTypeRequest) {
48+
func (dpv *describeFeatureTypeRequestParameterValue) parseDescribeFeatureTypeRequest(dft DescribeFeatureTypeRequest) []wsc110.Exception {
4949
dpv.request = describefeaturetype
5050
dpv.version = dft.Version
5151
dpv.service = dft.Service
5252
dpv.typeName = dft.TypeNames
5353
dpv.outputFormat = dft.OutputFormat
54+
return nil
5455
}
5556

5657
func (dpv describeFeatureTypeRequestParameterValue) toQueryParameters() url.Values {

pkg/wfs200/describefeaturetype_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ func TestDescribeFeatureTypeType(t *testing.T) {
1515
}
1616
}
1717

18-
//nolint:nestif
1918
func TestDescribeFeatureTypeParseXML(t *testing.T) {
2019
var tests = []struct {
2120
body []byte
@@ -101,7 +100,6 @@ func TestDescribeFeatureTypeParseXML(t *testing.T) {
101100
}
102101
}
103102

104-
//nolint:nestif
105103
func TestDescribeFeatureTypeParseQueryParameters(t *testing.T) {
106104
var tests = []struct {
107105
query url.Values

pkg/wfs200/exception.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package wfs200
22

33
import (
44
"encoding/xml"
5-
65
"github.com/pdok/ogc-specifications/pkg/wsc110"
76
)
87

pkg/wfs200/getcapabilities_request.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ func (g GetCapabilitiesRequest) Validate(_ wsc110.Capabilities) []wsc110.Excepti
2525

2626
// ParseXML builds a GetCapabilities object based on a XML document
2727
func (g *GetCapabilitiesRequest) ParseXML(doc []byte) []wsc110.Exception {
28-
var xmlAttributes utils.XMLAttribute
29-
if err := xml.Unmarshal(doc, &xmlAttributes); err != nil {
28+
var xmlattributes utils.XMLAttribute
29+
if err := xml.Unmarshal(doc, &xmlattributes); err != nil {
3030
return []wsc110.Exception{wsc110.NoApplicableCode("Could not process XML, is it XML?")}
3131
}
3232
if err := xml.Unmarshal(doc, &g); err != nil {
33-
return []wsc110.Exception{wsc110.OperationNotSupported(err.Error())} // TODO Should be OperationParsingFailed
33+
return []wsc110.Exception{wsc110.OperationNotSupported(err.Error())} //TODO Should be OperationParsingFailed
3434
}
3535
var n []xml.Attr
36-
for _, a := range xmlAttributes {
36+
for _, a := range xmlattributes {
3737
switch strings.ToUpper(a.Name.Local) {
3838
case VERSION:
3939
case SERVICE:
@@ -50,7 +50,7 @@ func (g *GetCapabilitiesRequest) ParseXML(doc []byte) []wsc110.Exception {
5050
func (g *GetCapabilitiesRequest) ParseQueryParameters(query url.Values) []wsc110.Exception {
5151
if len(query) == 0 {
5252
// When there are no query value we know that at least
53-
// the mandatory SERVICE and REQUEST parameter is missing.
53+
// the manadorty SERVICE and REQUEST parameter is missing.
5454
exceptions := wsc110.MissingParameterValue(SERVICE).ToExceptions()
5555
exceptions = append(exceptions, wsc110.MissingParameterValue(REQUEST))
5656
return exceptions
@@ -61,15 +61,15 @@ func (g *GetCapabilitiesRequest) ParseQueryParameters(query url.Values) []wsc110
6161
return exception
6262
}
6363

64-
if exception := g.parseGetCapabilitiesRequestParameterValue(gpv); exception != nil {
64+
if exception := g.parsegetCapabilitiesRequestParameterValue(gpv); exception != nil {
6565
return exception
6666
}
6767

6868
return nil
6969
}
7070

71-
// parseGetCapabilitiesRequestParameterValue process the simple struct to a complex struct
72-
func (g *GetCapabilitiesRequest) parseGetCapabilitiesRequestParameterValue(gpv getCapabilitiesRequestParameterValue) []wsc110.Exception {
71+
// parsegetCapabilitiesRequestParameterValue process the simple struct to a complex struct
72+
func (g *GetCapabilitiesRequest) parsegetCapabilitiesRequestParameterValue(gpv getCapabilitiesRequestParameterValue) []wsc110.Exception {
7373
g.XMLName.Local = gpv.request
7474
g.Service = gpv.service
7575
g.Version = gpv.version

pkg/wfs200/getcapabilities_response.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ type GetCapabilitiesResponse struct {
4747

4848
// Namespaces struct containing the namespaces needed for the XML document
4949
type Namespaces struct {
50-
XmlnsGML string `xml:"xmlns:gml,attr" yaml:"gml"` // http://www.opengis.net/gml/3.2
51-
XmlnsWFS string `xml:"xmlns,attr" yaml:"wfs"` // http://www.opengis.net/wfs/2.0
52-
XmlnsOWS string `xml:"xmlns:ows,attr" yaml:"common"` // http://www.opengis.net/ows/1.1
53-
XmlnsXlink string `xml:"xmlns:xlink,attr" yaml:"xlink"` // http://www.w3.org/1999/xlink
54-
XmlnsXSI string `xml:"xmlns:xsi,attr" yaml:"xsi"` // http://www.w3.org/2001/XMLSchema-instance
55-
XmlnsFes string `xml:"xmlns:fes,attr" yaml:"fes"` // http://www.opengis.net/fes/2.0
56-
XmlnsInspireCommon string `xml:"xmlns:inspire_common,attr,omitempty" yaml:"inspireCommon,omitempty"` // http://inspire.ec.europa.eu/schemas/common/1.0
57-
XmlnsInspireDls string `xml:"xmlns:inspire_dls,attr,omitempty" yaml:"inspireDls,omitempty"` // http://inspire.ec.europa.eu/schemas/inspire_dls/1.0
58-
XmlnsPrefix string `xml:"xmlns:{{.Prefix}},attr" yaml:"prefix"` // namespace_uri placeholder
50+
XmlnsGML string `xml:"xmlns:gml,attr" yaml:"gml"` //http://www.opengis.net/gml/3.2
51+
XmlnsWFS string `xml:"xmlns,attr" yaml:"wfs"` //http://www.opengis.net/wfs/2.0
52+
XmlnsOWS string `xml:"xmlns:ows,attr" yaml:"common"` //http://www.opengis.net/ows/1.1
53+
XmlnsXlink string `xml:"xmlns:xlink,attr" yaml:"xlink"` //http://www.w3.org/1999/xlink
54+
XmlnsXSI string `xml:"xmlns:xsi,attr" yaml:"xsi"` //http://www.w3.org/2001/XMLSchema-instance
55+
XmlnsFes string `xml:"xmlns:fes,attr" yaml:"fes"` //http://www.opengis.net/fes/2.0
56+
XmlnsInspireCommon string `xml:"xmlns:inspire_common,attr,omitempty" yaml:"inspireCommon,omitempty"` //http://inspire.ec.europa.eu/schemas/common/1.0
57+
XmlnsInspireDls string `xml:"xmlns:inspire_dls,attr,omitempty" yaml:"inspireDls,omitempty"` //http://inspire.ec.europa.eu/schemas/inspire_dls/1.0
58+
XmlnsPrefix string `xml:"xmlns:{{.Prefix}},attr" yaml:"prefix"` //namespace_uri placeholder
5959
Version string `xml:"version,attr" yaml:"version"`
6060
SchemaLocation string `xml:"xsi:schemaLocation,attr" yaml:"schemaLocation"`
6161
}

pkg/wfs200/getcapabilities_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ func TestGetCapabilitiesType(t *testing.T) {
1515
}
1616
}
1717

18-
//nolint:nestif
1918
func TestGetCapabilitiesParseXML(t *testing.T) {
2019
var tests = []struct {
2120
body []byte

0 commit comments

Comments
 (0)