Skip to content

Commit

Permalink
🐛 remove json marshaling that's not working (#577)
Browse files Browse the repository at this point in the history
This is not working, and actually making static report generation fail.

This is the error I see because of the custom MarshalJSON() function:

```
json: error calling MarshalJSON for type RuleSet: json: error calling MarshalJSON for type konveyor.Violation: json: unsupported type: map[interface {}]interface {}
```

Signed-off-by: Pranav Gaikwad <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
  • Loading branch information
pranavgaikwad authored and web-flow committed Apr 17, 2024
1 parent 3e35a11 commit b123cb2
Showing 1 changed file with 0 additions and 98 deletions.
98 changes: 0 additions & 98 deletions output/v1/konveyor/violations.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"go.lsp.dev/uri"
"gopkg.in/yaml.v2"
)

const (
Expand Down Expand Up @@ -53,28 +52,6 @@ func (r RuleSet) MarshalYAML() (interface{}, error) {
return r, nil
}

// NOTE(jsussman): Might have some performance issues.
//
// MarshalYAML's return value is (interface{}, error), meaning it simply
// propagates the object forward, unmarshalling whatever you return.
// MarshalJSON's return value is ([]byte, error), meaning you have to build the
// JSON yourself. You'd think we can simply call r.sortFields and then
// json.Marshal(r) like MarshalYAML, but that causes infinite recursion.
func (r RuleSet) MarshalJSON() ([]byte, error) {
b, err := yaml.Marshal(r)
if err != nil {
return b, err
}

m := map[string]any{}
err = yaml.Unmarshal(b, &m)
if err != nil {
return nil, err
}

return json.Marshal(m)
}

type Category string

var (
Expand Down Expand Up @@ -136,21 +113,6 @@ func (v Violation) MarshalYAML() (interface{}, error) {
return v, nil
}

func (v Violation) MarshalJSON() ([]byte, error) {
b, err := yaml.Marshal(v)
if err != nil {
return b, err
}

m := map[string]any{}
err = yaml.Unmarshal(b, &m)
if err != nil {
return nil, err
}

return json.Marshal(m)
}

// Incident defines instance of a violation
type Incident struct {
// URI defines location in the codebase where violation is found
Expand Down Expand Up @@ -276,21 +238,6 @@ func (d Dep) MarshalYAML() (interface{}, error) {
return d, nil
}

func (d Dep) MarshalJSON() ([]byte, error) {
b, err := yaml.Marshal(d)
if err != nil {
return b, err
}

m := map[string]any{}
err = yaml.Unmarshal(b, &m)
if err != nil {
return nil, err
}

return json.Marshal(m)
}

func (d *Dep) GetLabels() []string {
return d.Labels
}
Expand All @@ -316,21 +263,6 @@ func (d DepDAGItem) MarshalYAML() (interface{}, error) {
return d, nil
}

func (d DepDAGItem) MarshalJSON() ([]byte, error) {
b, err := yaml.Marshal(d)
if err != nil {
return b, err
}

m := map[string]any{}
err = yaml.Unmarshal(b, &m)
if err != nil {
return nil, err
}

return json.Marshal(m)
}

type DepsFlatItem struct {
FileURI string `yaml:"fileURI" json:"fileURI"`
Provider string `yaml:"provider" json:"provider"`
Expand All @@ -349,21 +281,6 @@ func (d DepsFlatItem) MarshalYAML() (interface{}, error) {
return d, nil
}

func (d DepsFlatItem) MarshalJSON() ([]byte, error) {
b, err := yaml.Marshal(d)
if err != nil {
return b, err
}

m := map[string]any{}
err = yaml.Unmarshal(b, &m)
if err != nil {
return nil, err
}

return json.Marshal(m)
}

type DepsTreeItem struct {
FileURI string `yaml:"fileURI" json:"fileURI"`
Provider string `yaml:"provider" json:"provider"`
Expand All @@ -382,18 +299,3 @@ func (d DepsTreeItem) MarshalYAML() (interface{}, error) {
d.sortFields()
return d, nil
}

func (d DepsTreeItem) MarshalJSON() ([]byte, error) {
b, err := yaml.Marshal(d)
if err != nil {
return b, err
}

m := map[string]any{}
err = yaml.Unmarshal(b, &m)
if err != nil {
return nil, err
}

return json.Marshal(m)
}

0 comments on commit b123cb2

Please sign in to comment.