Skip to content

Commit

Permalink
Address most of lint comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhen Zavhorodnii committed Feb 5, 2024
1 parent ba85b94 commit 628db8f
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 190 deletions.
33 changes: 0 additions & 33 deletions pkg/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,135 +195,102 @@ func (c *Config) Merge(config Config, values map[string]any) {
switch strings.ToLower(key) {
case strings.ToLower("Verbose"):
c.Verbose = config.Verbose
break

case strings.ToLower("AppFolder"):
c.AppFolder = config.AppFolder
break

case strings.ToLower("BinFolder"):
c.BinFolder = config.BinFolder
break

case strings.ToLower("DataFolder"):
c.DataFolder = config.DataFolder
break

case strings.ToLower("OutputFolder"):
c.OutputFolder = config.OutputFolder
break

case strings.ToLower("ServerFolder"):
c.ServerFolder = config.ServerFolder
break

case strings.ToLower("TempFolder"):
c.TempFolder = config.TempFolder
break

case strings.ToLower("KeyFolder"):
c.KeyFolder = config.KeyFolder
break

case strings.ToLower("InputFile"):
c.InputFile = config.InputFile
break

case strings.ToLower("DataFlowDiagramFilenamePNG"):
c.DataFlowDiagramFilenamePNG = config.DataFlowDiagramFilenamePNG
break

case strings.ToLower("DataAssetDiagramFilenamePNG"):
c.DataAssetDiagramFilenamePNG = config.DataAssetDiagramFilenamePNG
break

case strings.ToLower("DataFlowDiagramFilenameDOT"):
c.DataFlowDiagramFilenameDOT = config.DataFlowDiagramFilenameDOT
break

case strings.ToLower("DataAssetDiagramFilenameDOT"):
c.DataAssetDiagramFilenameDOT = config.DataAssetDiagramFilenameDOT
break

case strings.ToLower("ReportFilename"):
c.ReportFilename = config.ReportFilename
break

case strings.ToLower("ExcelRisksFilename"):
c.ExcelRisksFilename = config.ExcelRisksFilename
break

case strings.ToLower("ExcelTagsFilename"):
c.ExcelTagsFilename = config.ExcelTagsFilename
break

case strings.ToLower("JsonRisksFilename"):
c.JsonRisksFilename = config.JsonRisksFilename
break

case strings.ToLower("JsonTechnicalAssetsFilename"):
c.JsonTechnicalAssetsFilename = config.JsonTechnicalAssetsFilename
break

case strings.ToLower("JsonStatsFilename"):
c.JsonStatsFilename = config.JsonStatsFilename
break

case strings.ToLower("TemplateFilename"):
c.TemplateFilename = config.TemplateFilename
break

case strings.ToLower("RAAPlugin"):
c.RAAPlugin = config.RAAPlugin
break

case strings.ToLower("RiskRulesPlugins"):
c.RiskRulesPlugins = config.RiskRulesPlugins
break

case strings.ToLower("SkipRiskRules"):
c.SkipRiskRules = config.SkipRiskRules
break

case strings.ToLower("ExecuteModelMacro"):
c.ExecuteModelMacro = config.ExecuteModelMacro
break

case strings.ToLower("DiagramDPI"):
c.DiagramDPI = config.DiagramDPI
break

case strings.ToLower("ServerPort"):
c.ServerPort = config.ServerPort
break

case strings.ToLower("GraphvizDPI"):
c.GraphvizDPI = config.GraphvizDPI
break

case strings.ToLower("MaxGraphvizDPI"):
c.MaxGraphvizDPI = config.MaxGraphvizDPI
break

case strings.ToLower("BackupHistoryFilesToKeep"):
c.BackupHistoryFilesToKeep = config.BackupHistoryFilesToKeep
break

case strings.ToLower("AddModelTitle"):
c.AddModelTitle = config.AddModelTitle
break

case strings.ToLower("KeepDiagramSourceFiles"):
c.KeepDiagramSourceFiles = config.KeepDiagramSourceFiles
break

case strings.ToLower("IgnoreOrphanedRiskTracking"):
c.IgnoreOrphanedRiskTracking = config.IgnoreOrphanedRiskTracking
break

case strings.ToLower("Attractiveness"):
c.Attractiveness = config.Attractiveness
break
}
}
}
Expand Down
30 changes: 2 additions & 28 deletions pkg/input/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ package input

import (
"fmt"
"github.com/mpvl/unique"
"log"
"os"
"path/filepath"
"slices"
"sort"
"strings"

"github.com/mpvl/unique"

"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -115,167 +116,140 @@ func (model *Model) Merge(dir string, includeFilename string) error {
return fmt.Errorf("failed to merge model include %q: %v", includeFile, mergeError)
}
}
break

case strings.ToLower("threagile_version"):
model.ThreagileVersion, mergeError = new(Strings).MergeSingleton(model.ThreagileVersion, includedModel.ThreagileVersion)
if mergeError != nil {
return fmt.Errorf("failed to merge threagile version: %v", mergeError)
}
break

case strings.ToLower("title"):
model.Title, mergeError = new(Strings).MergeSingleton(model.Title, includedModel.Title)
if mergeError != nil {
return fmt.Errorf("failed to merge title: %v", mergeError)
}
break

case strings.ToLower("author"):
mergeError = model.Author.Merge(includedModel.Author)
if mergeError != nil {
return fmt.Errorf("failed to merge author: %v", mergeError)
}
break

case strings.ToLower("contributors"):
model.Contributors, mergeError = new(Author).MergeList(append(model.Contributors, includedModel.Author))
if mergeError != nil {
return fmt.Errorf("failed to merge contributors: %v", mergeError)
}
break

case strings.ToLower("date"):
model.Date, mergeError = new(Strings).MergeSingleton(model.Date, includedModel.Date)
if mergeError != nil {
return fmt.Errorf("failed to merge date: %v", mergeError)
}
break

case strings.ToLower("application_description"):
mergeError = model.AppDescription.Merge(includedModel.AppDescription)
if mergeError != nil {
return fmt.Errorf("failed to merge application description: %v", mergeError)
}
break

case strings.ToLower("business_overview"):
mergeError = model.BusinessOverview.Merge(includedModel.BusinessOverview)
if mergeError != nil {
return fmt.Errorf("failed to merge business overview: %v", mergeError)
}
break

case strings.ToLower("technical_overview"):
mergeError = model.TechnicalOverview.Merge(includedModel.TechnicalOverview)
if mergeError != nil {
return fmt.Errorf("failed to merge technical overview: %v", mergeError)
}
break

case strings.ToLower("business_criticality"):
model.BusinessCriticality, mergeError = new(Strings).MergeSingleton(model.BusinessCriticality, includedModel.BusinessCriticality)
if mergeError != nil {
return fmt.Errorf("failed to merge business criticality: %v", mergeError)
}
break

case strings.ToLower("management_summary_comment"):
model.ManagementSummaryComment = new(Strings).MergeMultiline(model.ManagementSummaryComment, includedModel.ManagementSummaryComment)
break

case strings.ToLower("security_requirements"):
model.SecurityRequirements, mergeError = new(Strings).MergeMap(model.SecurityRequirements, includedModel.SecurityRequirements)
if mergeError != nil {
return fmt.Errorf("failed to merge security requirements: %v", mergeError)
}
break

case strings.ToLower("questions"):
model.Questions, mergeError = new(Strings).MergeMap(model.Questions, includedModel.Questions)
if mergeError != nil {
return fmt.Errorf("failed to merge questions: %v", mergeError)
}
break

case strings.ToLower("abuse_cases"):
model.AbuseCases, mergeError = new(Strings).MergeMap(model.AbuseCases, includedModel.AbuseCases)
if mergeError != nil {
return fmt.Errorf("failed to merge abuse cases: %v", mergeError)
}
break

case strings.ToLower("tags_available"):
model.TagsAvailable = new(Strings).MergeUniqueSlice(model.TagsAvailable, includedModel.TagsAvailable)
break

case strings.ToLower("data_assets"):
model.DataAssets, mergeError = new(DataAsset).MergeMap(model.DataAssets, includedModel.DataAssets)
if mergeError != nil {
return fmt.Errorf("failed to merge data assets: %v", mergeError)
}
break

case strings.ToLower("technical_assets"):
model.TechnicalAssets, mergeError = new(TechnicalAsset).MergeMap(model.TechnicalAssets, includedModel.TechnicalAssets)
if mergeError != nil {
return fmt.Errorf("failed to merge technical assets: %v", mergeError)
}
break

case strings.ToLower("trust_boundaries"):
model.TrustBoundaries, mergeError = new(TrustBoundary).MergeMap(model.TrustBoundaries, includedModel.TrustBoundaries)
if mergeError != nil {
return fmt.Errorf("failed to merge trust boundaries: %v", mergeError)
}
break

case strings.ToLower("shared_runtimes"):
model.SharedRuntimes, mergeError = new(SharedRuntime).MergeMap(model.SharedRuntimes, includedModel.SharedRuntimes)
if mergeError != nil {
return fmt.Errorf("failed to merge shared runtimes: %v", mergeError)
}
break

case strings.ToLower("individual_risk_categories"):
model.IndividualRiskCategories, mergeError = new(IndividualRiskCategory).MergeMap(model.IndividualRiskCategories, includedModel.IndividualRiskCategories)
if mergeError != nil {
return fmt.Errorf("failed to merge risk categories: %v", mergeError)
}
break

case strings.ToLower("risk_tracking"):
model.RiskTracking, mergeError = new(RiskTracking).MergeMap(model.RiskTracking, includedModel.RiskTracking)
if mergeError != nil {
return fmt.Errorf("failed to merge risk tracking: %v", mergeError)
}
break

case "diagram_tweak_nodesep":
model.DiagramTweakNodesep = includedModel.DiagramTweakNodesep
break

case "diagram_tweak_ranksep":
model.DiagramTweakRanksep = includedModel.DiagramTweakRanksep
break

case "diagram_tweak_edge_layout":
model.DiagramTweakEdgeLayout = includedModel.DiagramTweakEdgeLayout
break

case "diagram_tweak_suppress_edge_labels":
model.DiagramTweakSuppressEdgeLabels = includedModel.DiagramTweakSuppressEdgeLabels
break

case "diagram_tweak_layout_left_to_right":
model.DiagramTweakLayoutLeftToRight = includedModel.DiagramTweakLayoutLeftToRight
break

case "diagram_tweak_invisible_connections_between_assets":
model.DiagramTweakInvisibleConnectionsBetweenAssets = append(model.DiagramTweakInvisibleConnectionsBetweenAssets, includedModel.DiagramTweakInvisibleConnectionsBetweenAssets...)
sort.Strings(model.DiagramTweakInvisibleConnectionsBetweenAssets)
unique.Strings(&model.DiagramTweakInvisibleConnectionsBetweenAssets)
break

case "diagram_tweak_same_rank_assets":
model.DiagramTweakSameRankAssets = append(model.DiagramTweakSameRankAssets, includedModel.DiagramTweakSameRankAssets...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/input/shared-runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "fmt"
type SharedRuntime struct {
ID string `yaml:"id,omitempty" json:"id,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Tags []string `yaml:"tags,omitempty" json:"tag,omitemptys"`
Tags []string `yaml:"tags,omitempty" json:"tag,omitempty"`
TechnicalAssetsRunning []string `yaml:"technical_assets_running,omitempty" json:"technical_assets_running,omitempty"`
}

Expand Down
Loading

0 comments on commit 628db8f

Please sign in to comment.