Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 remove json marshaling that's not working #577

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading