Skip to content

Commit 332c457

Browse files
thaJeztahjohandorland
authored andcommitted
golint: capitalize acronyms
jsonLoader.go:353:6: func decodeJsonUsingNumber should be decodeJSONUsingNumber schemaPool.go:153:2: var refToUrl should be refToURL utils.go:75:6: func marshalToJsonString should be marshalToJSONString utils.go:108:6: func isJsonNumber should be isJSONNumber utils.go:119:6: func checkJsonInteger should be checkJSONInteger utils.go:183:6: func resultErrorFormatJsonNumber should be resultErrorFormatJSONNumber Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 5fcca16 commit 332c457

File tree

8 files changed

+45
-45
lines changed

8 files changed

+45
-45
lines changed

jsonLoader.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ func (l *jsonReferenceLoader) LoadJSON() (interface{}, error) {
137137
return nil, err
138138
}
139139

140-
refToUrl := reference
141-
refToUrl.GetUrl().Fragment = ""
140+
refToURL := reference
141+
refToURL.GetUrl().Fragment = ""
142142

143143
var document interface{}
144144

145145
if reference.HasFileScheme {
146146

147-
filename := strings.TrimPrefix(refToUrl.String(), "file://")
147+
filename := strings.TrimPrefix(refToURL.String(), "file://")
148148
if runtime.GOOS == "windows" {
149149
// on Windows, a file URL may have an extra leading slash, use slashes
150150
// instead of backslashes, and have spaces escaped
@@ -159,7 +159,7 @@ func (l *jsonReferenceLoader) LoadJSON() (interface{}, error) {
159159

160160
} else {
161161

162-
document, err = l.loadFromHTTP(refToUrl.String())
162+
document, err = l.loadFromHTTP(refToURL.String())
163163
if err != nil {
164164
return nil, err
165165
}
@@ -175,7 +175,7 @@ func (l *jsonReferenceLoader) loadFromHTTP(address string) (interface{}, error)
175175
// returned cached versions for metaschemas for drafts 4, 6 and 7
176176
// for performance and allow for easier offline use
177177
if metaSchema := drafts.GetMetaSchema(address); metaSchema != "" {
178-
return decodeJsonUsingNumber(strings.NewReader(metaSchema))
178+
return decodeJSONUsingNumber(strings.NewReader(metaSchema))
179179
}
180180

181181
resp, err := http.Get(address)
@@ -193,7 +193,7 @@ func (l *jsonReferenceLoader) loadFromHTTP(address string) (interface{}, error)
193193
return nil, err
194194
}
195195

196-
return decodeJsonUsingNumber(bytes.NewReader(bodyBuff))
196+
return decodeJSONUsingNumber(bytes.NewReader(bodyBuff))
197197
}
198198

199199
func (l *jsonReferenceLoader) loadFromFile(path string) (interface{}, error) {
@@ -208,7 +208,7 @@ func (l *jsonReferenceLoader) loadFromFile(path string) (interface{}, error) {
208208
return nil, err
209209
}
210210

211-
return decodeJsonUsingNumber(bytes.NewReader(bodyBuff))
211+
return decodeJSONUsingNumber(bytes.NewReader(bodyBuff))
212212

213213
}
214214

@@ -237,7 +237,7 @@ func NewStringLoader(source string) JSONLoader {
237237

238238
func (l *jsonStringLoader) LoadJSON() (interface{}, error) {
239239

240-
return decodeJsonUsingNumber(strings.NewReader(l.JsonSource().(string)))
240+
return decodeJSONUsingNumber(strings.NewReader(l.JsonSource().(string)))
241241

242242
}
243243

@@ -265,7 +265,7 @@ func NewBytesLoader(source []byte) JSONLoader {
265265
}
266266

267267
func (l *jsonBytesLoader) LoadJSON() (interface{}, error) {
268-
return decodeJsonUsingNumber(bytes.NewReader(l.JsonSource().([]byte)))
268+
return decodeJSONUsingNumber(bytes.NewReader(l.JsonSource().([]byte)))
269269
}
270270

271271
// JSON Go (types) loader
@@ -301,7 +301,7 @@ func (l *jsonGoLoader) LoadJSON() (interface{}, error) {
301301
return nil, err
302302
}
303303

304-
return decodeJsonUsingNumber(bytes.NewReader(jsonBytes))
304+
return decodeJSONUsingNumber(bytes.NewReader(jsonBytes))
305305

306306
}
307307

@@ -326,7 +326,7 @@ func (l *jsonIOLoader) JsonSource() interface{} {
326326
}
327327

328328
func (l *jsonIOLoader) LoadJSON() (interface{}, error) {
329-
return decodeJsonUsingNumber(l.buf)
329+
return decodeJSONUsingNumber(l.buf)
330330
}
331331

332332
func (l *jsonIOLoader) JsonReference() (gojsonreference.JsonReference, error) {
@@ -362,7 +362,7 @@ func (l *jsonRawLoader) LoaderFactory() JSONLoaderFactory {
362362
return &DefaultJSONLoaderFactory{}
363363
}
364364

365-
func decodeJsonUsingNumber(r io.Reader) (interface{}, error) {
365+
func decodeJSONUsingNumber(r io.Reader) (interface{}, error) {
366366

367367
var document interface{}
368368

jsonschema_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ func executeTests(t *testing.T, path string) error {
9696
}
9797

9898
if result.Valid() != testCase.Valid {
99-
schemaString, _ := marshalToJsonString(test.Schema)
100-
testCaseString, _ := marshalToJsonString(testCase.Data)
99+
schemaString, _ := marshalToJSONString(test.Schema)
100+
testCaseString, _ := marshalToJSONString(testCase.Data)
101101

102102
t.Errorf("Test failed : %s\n"+
103103
"%s.\n"+

result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (v ResultErrorFields) String() string {
164164
if v.value == nil {
165165
valueString = TYPE_NULL
166166
} else {
167-
if vs, err := marshalToJsonString(v.value); err == nil {
167+
if vs, err := marshalToJSONString(v.value); err == nil {
168168
if vs == nil {
169169
valueString = TYPE_NULL
170170
} else {

schema.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ func (d *Schema) parseSchema(documentNode interface{}, currentSchema *subSchema)
509509
currentSchema.exclusiveMinimum = currentSchema.minimum
510510
currentSchema.minimum = nil
511511
}
512-
} else if isJsonNumber(m[KEY_EXCLUSIVE_MINIMUM]) {
512+
} else if isJSONNumber(m[KEY_EXCLUSIVE_MINIMUM]) {
513513
currentSchema.exclusiveMinimum = mustBeNumber(m[KEY_EXCLUSIVE_MINIMUM])
514514
} else {
515515
return errors.New(formatErrorDescription(
@@ -521,7 +521,7 @@ func (d *Schema) parseSchema(documentNode interface{}, currentSchema *subSchema)
521521
))
522522
}
523523
default:
524-
if isJsonNumber(m[KEY_EXCLUSIVE_MINIMUM]) {
524+
if isJSONNumber(m[KEY_EXCLUSIVE_MINIMUM]) {
525525
currentSchema.exclusiveMinimum = mustBeNumber(m[KEY_EXCLUSIVE_MINIMUM])
526526
} else {
527527
return errors.New(formatErrorDescription(
@@ -580,7 +580,7 @@ func (d *Schema) parseSchema(documentNode interface{}, currentSchema *subSchema)
580580
currentSchema.exclusiveMaximum = currentSchema.maximum
581581
currentSchema.maximum = nil
582582
}
583-
} else if isJsonNumber(m[KEY_EXCLUSIVE_MAXIMUM]) {
583+
} else if isJSONNumber(m[KEY_EXCLUSIVE_MAXIMUM]) {
584584
currentSchema.exclusiveMaximum = mustBeNumber(m[KEY_EXCLUSIVE_MAXIMUM])
585585
} else {
586586
return errors.New(formatErrorDescription(
@@ -592,7 +592,7 @@ func (d *Schema) parseSchema(documentNode interface{}, currentSchema *subSchema)
592592
))
593593
}
594594
default:
595-
if isJsonNumber(m[KEY_EXCLUSIVE_MAXIMUM]) {
595+
if isJSONNumber(m[KEY_EXCLUSIVE_MAXIMUM]) {
596596
currentSchema.exclusiveMaximum = mustBeNumber(m[KEY_EXCLUSIVE_MAXIMUM])
597597
} else {
598598
return errors.New(formatErrorDescription(

schemaPool.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ func (p *schemaPool) GetDocument(reference gojsonreference.JsonReference) (*sche
150150
}
151151

152152
// Create a deep copy, so we can remove the fragment part later on without altering the original
153-
refToUrl, _ := gojsonreference.NewJsonReference(reference.String())
153+
refToURL, _ := gojsonreference.NewJsonReference(reference.String())
154154

155155
// First check if the given fragment is a location independent identifier
156156
// http://json-schema.org/latest/json-schema-core.html#rfc.section.8.2.3
157157

158-
if spd, ok = p.schemaPoolDocuments[refToUrl.String()]; ok {
158+
if spd, ok = p.schemaPoolDocuments[refToURL.String()]; ok {
159159
if internalLogEnabled {
160160
internalLog(" From pool")
161161
}
@@ -165,9 +165,9 @@ func (p *schemaPool) GetDocument(reference gojsonreference.JsonReference) (*sche
165165
// If the given reference is not a location independent identifier,
166166
// strip the fragment and look for a document with it's base URI
167167

168-
refToUrl.GetUrl().Fragment = ""
168+
refToURL.GetUrl().Fragment = ""
169169

170-
if cachedSpd, ok := p.schemaPoolDocuments[refToUrl.String()]; ok {
170+
if cachedSpd, ok := p.schemaPoolDocuments[refToURL.String()]; ok {
171171
document, _, err := reference.GetPointer().Get(cachedSpd.Document)
172172

173173
if err != nil {
@@ -200,7 +200,7 @@ func (p *schemaPool) GetDocument(reference gojsonreference.JsonReference) (*sche
200200
}
201201

202202
// add the whole document to the pool for potential re-use
203-
p.parseReferences(document, refToUrl, true)
203+
p.parseReferences(document, refToURL, true)
204204

205205
_, draft, _ = parseSchemaURL(document)
206206

utils.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535

3636
func isKind(what interface{}, kinds ...reflect.Kind) bool {
3737
target := what
38-
if isJsonNumber(what) {
38+
if isJSONNumber(what) {
3939
// JSON Numbers are strings!
4040
target = *mustBeNumber(what)
4141
}
@@ -72,7 +72,7 @@ func indexStringInSlice(s []string, what string) int {
7272
return -1
7373
}
7474

75-
func marshalToJsonString(value interface{}) (*string, error) {
75+
func marshalToJSONString(value interface{}) (*string, error) {
7676

7777
mBytes, err := json.Marshal(value)
7878
if err != nil {
@@ -90,7 +90,7 @@ func marshalWithoutNumber(value interface{}) (*string, error) {
9090
// One way to eliminate these differences is to decode and encode the JSON one more time without Decoder.UseNumber
9191
// so that these differences in representation are removed
9292

93-
jsonString, err := marshalToJsonString(value)
93+
jsonString, err := marshalToJSONString(value)
9494
if err != nil {
9595
return nil, err
9696
}
@@ -102,10 +102,10 @@ func marshalWithoutNumber(value interface{}) (*string, error) {
102102
return nil, err
103103
}
104104

105-
return marshalToJsonString(document)
105+
return marshalToJSONString(document)
106106
}
107107

108-
func isJsonNumber(what interface{}) bool {
108+
func isJSONNumber(what interface{}) bool {
109109

110110
switch what.(type) {
111111

@@ -116,7 +116,7 @@ func isJsonNumber(what interface{}) bool {
116116
return false
117117
}
118118

119-
func checkJsonInteger(what interface{}) (isInt bool) {
119+
func checkJSONInteger(what interface{}) (isInt bool) {
120120

121121
jsonNumber := what.(json.Number)
122122

@@ -143,11 +143,11 @@ func isFloat64AnInteger(f float64) bool {
143143

144144
func mustBeInteger(what interface{}) *int {
145145

146-
if isJsonNumber(what) {
146+
if isJSONNumber(what) {
147147

148148
number := what.(json.Number)
149149

150-
isInt := checkJsonInteger(number)
150+
isInt := checkJSONInteger(number)
151151

152152
if isInt {
153153

@@ -167,7 +167,7 @@ func mustBeInteger(what interface{}) *int {
167167

168168
func mustBeNumber(what interface{}) *big.Rat {
169169

170-
if isJsonNumber(what) {
170+
if isJSONNumber(what) {
171171
number := what.(json.Number)
172172
float64Value, success := new(big.Rat).SetString(string(number))
173173
if success {
@@ -180,7 +180,7 @@ func mustBeNumber(what interface{}) *big.Rat {
180180
}
181181

182182
// formats a number so that it is displayed as the smallest string possible
183-
func resultErrorFormatJsonNumber(n json.Number) string {
183+
func resultErrorFormatJSONNumber(n json.Number) string {
184184

185185
if int64Value, err := n.Int64(); err == nil {
186186
return fmt.Sprintf("%d", int64Value)

utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ func TestCheckJsonNumber(t *testing.T) {
8484
}
8585

8686
for _, testCase := range testCases {
87-
assert.Equal(t, testCase.isInt, checkJsonInteger(testCase.value))
88-
assert.Equal(t, testCase.isInt, checkJsonInteger(testCase.value))
87+
assert.Equal(t, testCase.isInt, checkJSONInteger(testCase.value))
88+
assert.Equal(t, testCase.isInt, checkJSONInteger(testCase.value))
8989
}
9090

9191
}

validation.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ func (v *subSchema) validateRecursive(currentSubSchema *subSchema, currentNode i
101101

102102
} else { // Not a null value
103103

104-
if isJsonNumber(currentNode) {
104+
if isJSONNumber(currentNode) {
105105

106106
value := currentNode.(json.Number)
107107

108-
isInt := checkJsonInteger(value)
108+
isInt := checkJSONInteger(value)
109109

110110
validType := currentSubSchema.types.Contains(TYPE_NUMBER) || (isInt && currentSubSchema.types.Contains(TYPE_INTEGER))
111111

@@ -750,7 +750,7 @@ func (v *subSchema) validatePatternProperty(currentSubSchema *subSchema, key str
750750
func (v *subSchema) validateString(currentSubSchema *subSchema, value interface{}, result *Result, context *JsonContext) {
751751

752752
// Ignore JSON numbers
753-
if isJsonNumber(value) {
753+
if isJSONNumber(value) {
754754
return
755755
}
756756

@@ -819,7 +819,7 @@ func (v *subSchema) validateString(currentSubSchema *subSchema, value interface{
819819
func (v *subSchema) validateNumber(currentSubSchema *subSchema, value interface{}, result *Result, context *JsonContext) {
820820

821821
// Ignore non numbers
822-
if !isJsonNumber(value) {
822+
if !isJSONNumber(value) {
823823
return
824824
}
825825

@@ -837,7 +837,7 @@ func (v *subSchema) validateNumber(currentSubSchema *subSchema, value interface{
837837
result.addInternalError(
838838
new(MultipleOfError),
839839
context,
840-
resultErrorFormatJsonNumber(number),
840+
resultErrorFormatJSONNumber(number),
841841
ErrorDetails{"multiple": new(big.Float).SetRat(currentSubSchema.multipleOf)},
842842
)
843843
}
@@ -849,7 +849,7 @@ func (v *subSchema) validateNumber(currentSubSchema *subSchema, value interface{
849849
result.addInternalError(
850850
new(NumberLTEError),
851851
context,
852-
resultErrorFormatJsonNumber(number),
852+
resultErrorFormatJSONNumber(number),
853853
ErrorDetails{
854854
"max": currentSubSchema.maximum,
855855
},
@@ -861,7 +861,7 @@ func (v *subSchema) validateNumber(currentSubSchema *subSchema, value interface{
861861
result.addInternalError(
862862
new(NumberLTError),
863863
context,
864-
resultErrorFormatJsonNumber(number),
864+
resultErrorFormatJSONNumber(number),
865865
ErrorDetails{
866866
"max": currentSubSchema.exclusiveMaximum,
867867
},
@@ -875,7 +875,7 @@ func (v *subSchema) validateNumber(currentSubSchema *subSchema, value interface{
875875
result.addInternalError(
876876
new(NumberGTEError),
877877
context,
878-
resultErrorFormatJsonNumber(number),
878+
resultErrorFormatJSONNumber(number),
879879
ErrorDetails{
880880
"min": currentSubSchema.minimum,
881881
},
@@ -888,7 +888,7 @@ func (v *subSchema) validateNumber(currentSubSchema *subSchema, value interface{
888888
result.addInternalError(
889889
new(NumberGTError),
890890
context,
891-
resultErrorFormatJsonNumber(number),
891+
resultErrorFormatJSONNumber(number),
892892
ErrorDetails{
893893
"min": currentSubSchema.exclusiveMinimum,
894894
},

0 commit comments

Comments
 (0)