From 2618aa0b9653a46b5a2c8ea803a9a8c640dca1e2 Mon Sep 17 00:00:00 2001 From: Minhaj Uddin Khan Date: Thu, 24 Jan 2019 01:00:04 +0500 Subject: [PATCH] Add spaces before comments and Fix spell checks --- generator/manipulation.go | 14 +++++++------- generator/mapper.go | 21 +++++++++++---------- generator/profile.go | 2 +- generator/reader.go | 8 ++++---- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/generator/manipulation.go b/generator/manipulation.go index b92c0437..60f8a546 100644 --- a/generator/manipulation.go +++ b/generator/manipulation.go @@ -13,7 +13,7 @@ import ( "github.com/docker/oscalkit/types/oscal/profile" ) -//ProcessAddition processess additions of a profile +// ProcessAddition processes additions of a profile func ProcessAddition(alt profile.Alter, controls []catalog.Control) []catalog.Control { for j, ctrl := range controls { if ctrl.Id == alt.ControlId { @@ -23,7 +23,7 @@ func ProcessAddition(alt profile.Alter, controls []catalog.Control) []catalog.Co for _, catalogPart := range ctrl.Parts { if p.Class == catalogPart.Class { appended = true - //append with all the parts with matching classes + // append with all the parts with matching classes parts := ModifyParts(p, ctrl.Parts) ctrl.Parts = parts } @@ -43,7 +43,7 @@ func ProcessAddition(alt profile.Alter, controls []catalog.Control) []catalog.Co for _, catalogPart := range subctrl.Parts { if p.Class == catalogPart.Class { appended = true - //append with all the parts + // append with all the parts parts := ModifyParts(p, subctrl.Parts) subctrl.Parts = parts } @@ -61,7 +61,7 @@ func ProcessAddition(alt profile.Alter, controls []catalog.Control) []catalog.Co return controls } -//ProcessAlteration processess alteration section of a profile +// ProcessAlteration processes alteration section of a profile func ProcessAlteration(alterations []profile.Alter, c *catalog.Catalog) *catalog.Catalog { for _, alt := range alterations { for i, g := range c.Groups { @@ -71,10 +71,10 @@ func ProcessAlteration(alterations []profile.Alter, c *catalog.Catalog) *catalog return c } -//ModifyParts modifies parts +// ModifyParts modifies parts func ModifyParts(p catalog.Part, controlParts []catalog.Part) []catalog.Part { - //append with all the parts + // append with all the parts var parts []catalog.Part for i, part := range controlParts { if p.Class != part.Class { @@ -90,7 +90,7 @@ func ModifyParts(p catalog.Part, controlParts []catalog.Part) []catalog.Part { return parts } -//FindAlter finds alter manipulation attribute in the profile import chain +// FindAlter finds alter manipulation attribute in the profile import chain func FindAlter(call profile.Call, p *profile.Profile) (*profile.Alter, error) { ec := make(chan error) diff --git a/generator/mapper.go b/generator/mapper.go index c114d14b..a24d3f14 100644 --- a/generator/mapper.go +++ b/generator/mapper.go @@ -11,7 +11,7 @@ import ( "github.com/docker/oscalkit/types/oscal/profile" ) -//CreateCatalogsFromProfile maps profile controls to multiple catalogs +// CreateCatalogsFromProfile maps profile controls to multiple catalogs func CreateCatalogsFromProfile(profileArg *profile.Profile) ([]*catalog.Catalog, error) { done := 0 @@ -22,7 +22,7 @@ func CreateCatalogsFromProfile(profileArg *profile.Profile) ([]*catalog.Catalog, if err != nil { return nil, err } - //Get first import of the profile (which is a catalog) + // Get first import of the profile (which is a catalog) for _, profileImport := range profileArg.Imports { go func(profileImport profile.Import) { c := make(chan *catalog.Catalog) @@ -30,11 +30,11 @@ func CreateCatalogsFromProfile(profileArg *profile.Profile) ([]*catalog.Catalog, ctx, cancel := context.WithCancel(context.Background()) defer cancel() - //ForEach Import's Href, Fetch the Catalog JSON file + // ForEach Import's Href, Fetch the Catalog JSON file getCatalogForImport(ctx, profileImport, c, e) select { case importedCatalog := <-c: - //Prepare a new catalog object to merge into the final List of OutputCatalogs + // Prepare a new catalog object to merge into the final List of OutputCatalogs if profileArg.Modify != nil { importedCatalog = ProcessAlteration(profileArg.Modify.Alterations, importedCatalog) } @@ -69,13 +69,14 @@ func CreateCatalogsFromProfile(profileArg *profile.Profile) ([]*catalog.Catalog, } } +// GetMappedCatalogControlsFromImport gets mapped controls in catalog per profile import func GetMappedCatalogControlsFromImport(importedCatalog *catalog.Catalog, profileImport profile.Import) (catalog.Catalog, error) { newCatalog := catalog.Catalog{ Title: importedCatalog.Title, Groups: []catalog.Group{}, } for _, group := range importedCatalog.Groups { - //Prepare a new group to append matching controls into. + // Prepare a new group to append matching controls into. newGroup := catalog.Group{ Title: group.Title, Controls: []catalog.Control{}, @@ -97,10 +98,10 @@ func GetMappedCatalogControlsFromImport(importedCatalog *catalog.Catalog, profil Params: catalogControl.Params, Parts: catalogControl.Parts, } - //For subcontrols, find again in entire profile + // For subcontrols, find again in entire profile for _, catalogSubControl := range catalogControl.Subcontrols { for subcontrolIndex, subcontrol := range include.IdSelectors { - //if found append the subcontrol into the control attribute + // If found append the subcontrol into the control attribute if strings.ToLower(catalogSubControl.Id) == strings.ToLower(subcontrol.SubcontrolId) { newControl.Subcontrols = append(newControl.Subcontrols, catalog.Subcontrol{ Id: catalogSubControl.Id, @@ -108,15 +109,15 @@ func GetMappedCatalogControlsFromImport(importedCatalog *catalog.Catalog, profil Title: catalogSubControl.Title, Parts: catalogSubControl.Parts, }) - //remove that subcontrol from profile. (for less computation) + // Remove that subcontrol from profile. (for less computation) include.IdSelectors = append(include.IdSelectors[:subcontrolIndex], include.IdSelectors[subcontrolIndex+1:]...) break } } } - //finally append the control in the group. + // Finally append the control in the group. newGroup.Controls = append(newGroup.Controls, newControl) - //remove controlId from profile as well. (for less computation) + // Remove controlId from profile as well. (for less computation) include.IdSelectors = append(include.IdSelectors[:controlIndex], profileImport.Include.IdSelectors[controlIndex+1:]...) break } diff --git a/generator/profile.go b/generator/profile.go index a82e118e..675616bb 100644 --- a/generator/profile.go +++ b/generator/profile.go @@ -4,7 +4,7 @@ import ( "github.com/docker/oscalkit/types/oscal/profile" ) -//AppendAlterations appends alter attributes from import chain +// AppendAlterations appends alter attributes from import chain func AppendAlterations(p *profile.Profile) (*profile.Profile, error) { if p.Modify == nil { p.Modify = &profile.Modify{ diff --git a/generator/reader.go b/generator/reader.go index 0d8a9ef1..e39c79d3 100644 --- a/generator/reader.go +++ b/generator/reader.go @@ -16,7 +16,7 @@ import ( "github.com/docker/oscalkit/types/oscal/profile" ) -//ReadCatalog ReadCatalog +// ReadCatalog ReadCatalog func ReadCatalog(r io.Reader) (*catalog.Catalog, error) { o, err := oscal.New(r) @@ -32,7 +32,7 @@ func ReadCatalog(r io.Reader) (*catalog.Catalog, error) { } -//ReadProfile reads profile from byte array +// ReadProfile reads profile from byte array func ReadProfile(r io.Reader) (*profile.Profile, error) { o, err := oscal.New(r) @@ -45,7 +45,7 @@ func ReadProfile(r io.Reader) (*profile.Profile, error) { return o.Profile, nil } -//GetFilePath GetFilePath +// GetFilePath GetFilePath func GetFilePath(URL string) (string, error) { uri, err := url.Parse(URL) if err != nil { @@ -74,7 +74,7 @@ func GetFilePath(URL string) (string, error) { } -//GetAbsolutePath gets absolute file path +// GetAbsolutePath gets absolute file path func GetAbsolutePath(path string) (string, error) { if filepath.IsAbs(path) { return path, nil