Skip to content

Commit

Permalink
fix check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
simitt committed Sep 3, 2020
1 parent 313a4e2 commit 1c456f0
Show file tree
Hide file tree
Showing 8 changed files with 514 additions and 562 deletions.
46 changes: 0 additions & 46 deletions model/modeldecoder/cloud.go

This file was deleted.

6 changes: 3 additions & 3 deletions model/modeldecoder/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ if !%s.MatchString(k){
if types, ok := parts[ruleTypesVals]; ok {
delete(parts, ruleTypesVals)
fmt.Fprintf(&g.buf, `
switch v.(type){
switch t := v.(type){
`[1:])
if !required {
fmt.Fprintf(&g.buf, `
Expand All @@ -335,7 +335,7 @@ case %s:
if maxVal, ok := parts[ruleMaxVals]; ok {
delete(parts, ruleMaxVals)
fmt.Fprintf(&g.buf, `
if utf8.RuneCountInString(v.(string)) > %s{
if utf8.RuneCountInString(t) > %s{
return fmt.Errorf("validation rule '%s(%s)' violated for '%s'")
}
`[1:], maxVal, ruleMaxVals, maxVal, flattenedName)
Expand Down Expand Up @@ -469,7 +469,7 @@ if m.%s.IsNil(){
}
func jsonName(f structField) string {
parts := parseTag(f.tag, "json")
if parts == nil || len(parts) == 0 {
if len(parts) == 0 {
return strings.ToLower(f.name)
}
return parts[0]
Expand Down
2 changes: 1 addition & 1 deletion model/modeldecoder/rumv3/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func DecodeMetadata(d decoder.Decoder, out *model.Metadata) error {
if err := d.Decode(&m); err != nil {
return err
}
if err := m.Metadata.validate(); err != nil {
if err := m.validate(); err != nil {
return err
}
mapToModel(&m.Metadata, out)
Expand Down
4 changes: 2 additions & 2 deletions model/modeldecoder/rumv3/model_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func (m *metadata) validate() error {
if !labelsRegex.MatchString(k) {
return fmt.Errorf("validation rule 'patternKeys(labelsRegex)' violated for 'm.l'")
}
switch v.(type) {
switch t := v.(type) {
case nil:
case string:
if utf8.RuneCountInString(v.(string)) > 1024 {
if utf8.RuneCountInString(t) > 1024 {
return fmt.Errorf("validation rule 'maxVals(1024)' violated for 'm.l'")
}
case bool:
Expand Down
2 changes: 0 additions & 2 deletions model/modeldecoder/typ/typ.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ func init() {

}

var json = jsoniter.ConfigCompatibleWithStandardLibrary

type String struct {
Val string
isSet bool
Expand Down
8 changes: 3 additions & 5 deletions model/modeldecoder/v2/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ import (
"net"
"sync"

"github.com/minio/simdjson-go"

"github.com/elastic/apm-server/decoder"
"github.com/elastic/apm-server/model"
"github.com/elastic/beats/v7/libbeat/common"
)

var (
simdjsonSupported = simdjson.SupportedCPU()
)
// var (
// simdjsonSupported = simdjson.SupportedCPU()
// )

func init() {
metadataPool.New = func() interface{} {
Expand Down
4 changes: 2 additions & 2 deletions model/modeldecoder/v2/model_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ func (m *metadata) validate() error {
if !labelsRegex.MatchString(k) {
return fmt.Errorf("validation rule 'patternKeys(labelsRegex)' violated for 'metadata.labels'")
}
switch v.(type) {
switch t := v.(type) {
case nil:
case string:
if utf8.RuneCountInString(v.(string)) > 1024 {
if utf8.RuneCountInString(t) > 1024 {
return fmt.Errorf("validation rule 'maxVals(1024)' violated for 'metadata.labels'")
}
case bool:
Expand Down
Loading

0 comments on commit 1c456f0

Please sign in to comment.