File tree 3 files changed +17
-2
lines changed
3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ require (
29
29
github.com/BurntSushi/toml v1.2.1 // indirect
30
30
github.com/VividCortex/ewma v1.1.1 // indirect
31
31
github.com/antchfx/xpath v1.2.0 // indirect
32
+ github.com/cevaris/ordered_map v0.0.0-20220813181356-34664b69742b // indirect
32
33
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
33
34
github.com/fatih/color v1.13.0 // indirect
34
35
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ github.com/antchfx/xpath v1.2.0 h1:mbwv7co+x0RwgeGAOHdrKy89GvHaGvxxBtPK0uF9Zr8=
14
14
github.com/antchfx/xpath v1.2.0 /go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs =
15
15
github.com/bmatcuk/doublestar/v4 v4.0.2 h1:X0krlUVAVmtr2cRoTqR8aDMrDqnB36ht8wpWTiQ3jsA =
16
16
github.com/bmatcuk/doublestar/v4 v4.0.2 /go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc =
17
+ github.com/cevaris/ordered_map v0.0.0-20220813181356-34664b69742b h1:3G9nSrTyBZcQMI9phQK1XvSDCb8E6b1+6E5dcr+R2MU =
18
+ github.com/cevaris/ordered_map v0.0.0-20220813181356-34664b69742b /go.mod h1:dcE/RHCVM8522lLVHLcdgxCuQEYE5Zhn6VPXcxALaNs =
17
19
github.com/cheggaaa/pb/v3 v3.0.8 h1:bC8oemdChbke2FHIIGy9mn4DPJ2caZYQnfbRqwmdCoA =
18
20
github.com/cheggaaa/pb/v3 v3.0.8 /go.mod h1:UICbiLec/XO6Hw6k+BHEtHeQFzzBH4i2/qk/ow1EJTA =
19
21
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w =
Original file line number Diff line number Diff line change 8
8
"github.com/FileFormatInfo/fflint/internal/shared"
9
9
"github.com/adrg/frontmatter"
10
10
"github.com/spf13/cobra"
11
+ yamlv2 "gopkg.in/yaml.v2"
11
12
"gopkg.in/yaml.v3"
12
13
)
13
14
@@ -68,7 +69,7 @@ func frontmatterCheck(f *shared.FileContext) {
68
69
}
69
70
}
70
71
71
- yamlRawData := make (map [string ]any )
72
+ yamlRawData := make (map [any ]any )
72
73
//LATER: maybe flag to require contents?
73
74
_ , parseErr := frontmatter .MustParse (bytes .NewReader (data ), & yamlRawData , formats ... )
74
75
@@ -116,8 +117,19 @@ func frontmatterCheck(f *shared.FileContext) {
116
117
}
117
118
118
119
if fmSorted {
120
+ sortedData := yamlv2.MapSlice {}
121
+
122
+ frontmatter .Parse (bytes .NewReader (data ), & sortedData )
119
123
previousKey := ""
120
- for currentKey := range yamlData {
124
+ for _ , item := range sortedData {
125
+ currentKey , strErr := item .Key .(string )
126
+ if ! strErr {
127
+ f .RecordResult ("frontmatterSortedParse" , false , map [string ]interface {}{
128
+ "err" : "key is not a string" ,
129
+ "key" : fmt .Sprintf ("%v" , item .Key ),
130
+ })
131
+ continue
132
+ }
121
133
f .RecordResult ("frontmatterSorted" , previousKey < currentKey , map [string ]interface {}{
122
134
"previous" : previousKey ,
123
135
"current" : currentKey ,
You can’t perform that action at this time.
0 commit comments