Skip to content

Commit

Permalink
Fix lint problems for component refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
James C. Scott committed Aug 19, 2016
1 parent c1ba001 commit 237bbfc
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/components/versions/2_0_0/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,32 @@ type Component struct {
SchemaVersion semver.Version `yaml:"-" json:"-"`
}

// GetName returns the name of the component
func (c Component) GetName() string {
return c.Name
}

// GetKey returns the key for the component (may not be unique). Useful for creating directories.
func (c Component) GetKey() string {
return c.Key
}

// SetKey sets the key for the component. Useful for overriding.
func (c *Component) SetKey(key string) {
c.Key = key
}

// GetVerifications get all the verifications.
func (c Component) GetVerifications() *common.VerificationReferences {
return &c.Verifications
}

// GetReferences get all the references.
func (c Component) GetReferences() *common.GeneralReferences {
return &c.References
}

// GetAllSatisfies gets all the Satisfies objects for the component.
func (c Component) GetAllSatisfies() []common.Satisfies {
// Have to do manual conversion from this Component's Satisfies to the interface base.Satisfies.
baseSatisfies := make([]common.Satisfies, len(c.Satisfies))
Expand All @@ -45,14 +51,17 @@ func (c Component) GetAllSatisfies() []common.Satisfies {
return baseSatisfies
}

// GetVersion returns the version
func (c Component) GetVersion() semver.Version {
return c.SchemaVersion
}

// SetVersion sets the version for the component.
func (c *Component) SetVersion(version semver.Version) {
c.SchemaVersion = version
}

// GetResponsibleRole gets the responsible party / role for the component.
func (c Component) GetResponsibleRole() string {
return ""
}
Expand All @@ -69,14 +78,17 @@ type Satisfies struct {
ImplementationStatus string `yaml:"implementation_status" json:"implementation_status"`
}

// GetControlKey returns the control
func (s Satisfies) GetControlKey() string {
return s.ControlKey
}

// GetStandardKey returns the standard
func (s Satisfies) GetStandardKey() string {
return s.StandardKey
}

// GetNarratives gets all the general documentation for this particular standard and control
func (s Satisfies) GetNarratives() []common.Section {
// Have to do manual conversion to the interface base.Section.
// V2.0.0 only had one Narrative field, so if it actually exists, let's create a slice of 1 to return.
Expand All @@ -89,36 +101,45 @@ func (s Satisfies) GetNarratives() []common.Section {
return baseNarrative
}

// GetParameters gets all the parameters for this particular standard and control
func (s Satisfies) GetParameters() []common.Section {
return nil
}

// GetCoveredBy gets the list of all the CoveredBy
func (s Satisfies) GetCoveredBy() common.CoveredByList {
return s.CoveredBy
}

// GetControlOrigin returns the control origin (empty string for this version)
func (s Satisfies) GetControlOrigin() string {
return ""
}

// GetControlOrigins returns all the control origins (empty slice for this version)
func (s Satisfies) GetControlOrigins() []string {
return []string{}
}

// Narrative is the representation of the general documentation for a particular standard and control for the component.
type Narrative string

// GetKey returns a unique key (empty string for this version)
func (n Narrative) GetKey() string {
return ""
}

// GetText returns the text for the section
func (n Narrative) GetText() string {
return string(n)
}

// GetImplementationStatus returns the implementation status
func (s Satisfies) GetImplementationStatus() string {
return s.ImplementationStatus
}

// GetImplementationStatuses returns all implementation statuses (just the only one for this version)
func (s Satisfies) GetImplementationStatuses() []string {
return []string{}
}
22 changes: 22 additions & 0 deletions lib/components/versions/3_0_0/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,32 @@ type Component struct {
SchemaVersion semver.Version `yaml:"-" json:"-"`
}

// GetName returns the name of the component
func (c Component) GetName() string {
return c.Name
}

// GetKey returns the key for the component (may not be unique). Useful for creating directories.
func (c Component) GetKey() string {
return c.Key
}

// SetKey sets the key for the component. Useful for overriding.
func (c *Component) SetKey(key string) {
c.Key = key
}

// GetVerifications get all the verifications.
func (c Component) GetVerifications() *common.VerificationReferences {
return &c.Verifications
}

// GetReferences get all the references.
func (c Component) GetReferences() *common.GeneralReferences {
return &c.References
}

// GetAllSatisfies gets all the Satisfies objects for the component.
func (c Component) GetAllSatisfies() []common.Satisfies {
// Have to do manual conversion from this Component's Satisfies to the interface base.Satisfies.
baseSatisfies := make([]common.Satisfies, len(c.Satisfies))
Expand All @@ -46,14 +52,17 @@ func (c Component) GetAllSatisfies() []common.Satisfies {
return baseSatisfies
}

// GetVersion returns the version
func (c Component) GetVersion() semver.Version {
return c.SchemaVersion
}

// SetVersion sets the version for the component.
func (c *Component) SetVersion(version semver.Version) {
c.SchemaVersion = version
}

// GetResponsibleRole gets the responsible party / role for the component.
func (c Component) GetResponsibleRole() string {
return c.ResponsibleRole
}
Expand All @@ -72,14 +81,17 @@ type Satisfies struct {
ImplementationStatus string `yaml:"implementation_status" json:"implementation_status"`
}

// GetControlKey returns the control
func (s Satisfies) GetControlKey() string {
return s.ControlKey
}

// GetStandardKey returns the standard
func (s Satisfies) GetStandardKey() string {
return s.StandardKey
}

// GetNarratives gets all the general documentation for this particular standard and control
func (s Satisfies) GetNarratives() []common.Section {
// Have to do manual conversion to the interface base.Section from NarrativeSection.
baseSection := make([]common.Section, len(s.Narrative))
Expand All @@ -89,6 +101,7 @@ func (s Satisfies) GetNarratives() []common.Section {
return baseSection
}

// GetParameters gets all the parameters for this particular standard and control
func (s Satisfies) GetParameters() []common.Section {
// Have to do manual conversion to the interface base.Section from Section.
baseSection := make([]common.Section, len(s.Parameters))
Expand All @@ -98,22 +111,27 @@ func (s Satisfies) GetParameters() []common.Section {
return baseSection
}

// GetCoveredBy gets the list of all the CoveredBy
func (s Satisfies) GetCoveredBy() common.CoveredByList {
return s.CoveredBy
}

// GetControlOrigin returns the control origin (only the first one if multiple)
func (s Satisfies) GetControlOrigin() string {
return s.ControlOrigin
}

// GetControlOrigins returns all the control origins
func (s Satisfies) GetControlOrigins() []string {
return []string{s.ControlOrigin}
}

// GetImplementationStatus returns the implementation status (only the first one if multiple)
func (s Satisfies) GetImplementationStatus() string {
return s.ImplementationStatus
}

// GetImplementationStatuses returns all implementation statuses
func (s Satisfies) GetImplementationStatuses() []string {
return []string{}
}
Expand All @@ -125,10 +143,12 @@ type NarrativeSection struct {
Text string `yaml:"text" json:"text"`
}

// GetKey returns a unique key
func (ns NarrativeSection) GetKey() string {
return ns.Key
}

// GetText returns the text for the section
func (ns NarrativeSection) GetText() string {
return ns.Text
}
Expand All @@ -139,10 +159,12 @@ type Section struct {
Text string `yaml:"text" json:"text"`
}

// GetKey returns a unique key
func (s Section) GetKey() string {
return s.Key
}

// GetText returns the text for the section
func (s Section) GetText() string {
return s.Text
}
22 changes: 22 additions & 0 deletions lib/components/versions/3_1_0/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,32 @@ type Component struct {
SchemaVersion semver.Version `yaml:"-" json:"-"`
}

// GetName returns the name of the component
func (c Component) GetName() string {
return c.Name
}

// GetKey returns the key for the component (may not be unique). Useful for creating directories.
func (c Component) GetKey() string {
return c.Key
}

// SetKey sets the key for the component. Useful for overriding.
func (c *Component) SetKey(key string) {
c.Key = key
}

// GetVerifications get all the verifications.
func (c Component) GetVerifications() *common.VerificationReferences {
return &c.Verifications
}

// GetReferences get all the references.
func (c Component) GetReferences() *common.GeneralReferences {
return &c.References
}

// GetAllSatisfies gets all the Satisfies objects for the component.
func (c Component) GetAllSatisfies() []common.Satisfies {
// Have to do manual conversion from this Component's Satisfies to the interface base.Satisfies.
baseSatisfies := make([]common.Satisfies, len(c.Satisfies))
Expand All @@ -49,14 +55,17 @@ func (c Component) GetAllSatisfies() []common.Satisfies {
return baseSatisfies
}

// GetVersion returns the version
func (c Component) GetVersion() semver.Version {
return c.SchemaVersion
}

// SetVersion sets the version for the component.
func (c *Component) SetVersion(version semver.Version) {
c.SchemaVersion = version
}

// GetResponsibleRole gets the responsible party / role for the component.
func (c Component) GetResponsibleRole() string {
return c.ResponsibleRole
}
Expand All @@ -77,14 +86,17 @@ type Satisfies struct {
ImplementationStatuses []string `yaml:"implementation_statuses" json:"implementation_statuses"`
}

// GetControlKey returns the control
func (s Satisfies) GetControlKey() string {
return s.ControlKey
}

// GetStandardKey returns the standard
func (s Satisfies) GetStandardKey() string {
return s.StandardKey
}

// GetNarratives gets all the general documentation for this particular standard and control
func (s Satisfies) GetNarratives() []common.Section {
// Have to do manual conversion to the interface base.Section from NarrativeSection.
baseSection := make([]common.Section, len(s.Narrative))
Expand All @@ -94,6 +106,7 @@ func (s Satisfies) GetNarratives() []common.Section {
return baseSection
}

// GetParameters gets all the parameters for this particular standard and control
func (s Satisfies) GetParameters() []common.Section {
// Have to do manual conversion to the interface base.Section from Section.
baseSection := make([]common.Section, len(s.Parameters))
Expand All @@ -103,14 +116,17 @@ func (s Satisfies) GetParameters() []common.Section {
return baseSection
}

// GetCoveredBy gets the list of all the CoveredBy
func (s Satisfies) GetCoveredBy() common.CoveredByList {
return s.CoveredBy
}

// GetControlOrigin returns the control origin (only the first one if multiple)
func (s Satisfies) GetControlOrigin() string {
return s.ControlOrigin
}

// GetControlOrigins returns all the control origins
func (s Satisfies) GetControlOrigins() []string {
controlOrigins := set.New()
for i := range s.ControlOrigins {
Expand All @@ -124,10 +140,12 @@ func (s Satisfies) GetControlOrigins() []string {
return l
}

// GetImplementationStatus returns the implementation status (only the first one if multiple)
func (s Satisfies) GetImplementationStatus() string {
return s.ImplementationStatus
}

// GetImplementationStatuses returns all implementation statuses
func (s Satisfies) GetImplementationStatuses() []string {
implementationStatuses := set.New()
for i := range s.ImplementationStatuses {
Expand All @@ -148,10 +166,12 @@ type NarrativeSection struct {
Text string `yaml:"text" json:"text"`
}

// GetKey returns a unique key
func (ns NarrativeSection) GetKey() string {
return ns.Key
}

// GetText returns the text for the section
func (ns NarrativeSection) GetText() string {
return ns.Text
}
Expand All @@ -162,10 +182,12 @@ type Section struct {
Text string `yaml:"text" json:"text"`
}

// GetKey returns a unique key
func (s Section) GetKey() string {
return s.Key
}

// GetText returns the text for the section
func (s Section) GetText() string {
return s.Text
}

0 comments on commit 237bbfc

Please sign in to comment.