Skip to content

Commit

Permalink
fix: ignore unnecessary sonarcloud test file issues and rename fallba…
Browse files Browse the repository at this point in the history
…ck members for better understanding
  • Loading branch information
fschade committed Mar 5, 2024
1 parent 3ffb06e commit a6277e7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
16 changes: 8 additions & 8 deletions ocis-pkg/x/io/fsx/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ var (
// FallbackFS is a filesystem that layers a primary filesystem on top of a secondary filesystem.
type FallbackFS struct {
FS
layer *BaseFS
base *BaseFS
primary *BaseFS
secondary *BaseFS
}

// Primary returns the primary filesystem.
func (d *FallbackFS) Primary() *BaseFS {
return d.base
return d.primary
}

// Secondary returns the secondary filesystem.
func (d *FallbackFS) Secondary() *BaseFS {
return d.layer
return d.secondary
}

// NewFallbackFS returns a new FallbackFS instance.
func NewFallbackFS(base, layer FS) *FallbackFS {
func NewFallbackFS(primary, secondary FS) *FallbackFS {
return &FallbackFS{
FS: FromAfero(afero.NewCopyOnWriteFs(layer, base)),
base: &BaseFS{Fs: base},
layer: &BaseFS{Fs: layer},
FS: FromAfero(afero.NewCopyOnWriteFs(secondary, primary)),
primary: &BaseFS{Fs: primary},
secondary: &BaseFS{Fs: secondary},
}
}
10 changes: 4 additions & 6 deletions services/web/pkg/server/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ func Server(opts ...Option) (http.Service, error) {
fsx.NewBasePathFs(fsx.NewOsFs(), options.Config.Asset.CorePath),
fsx.NewBasePathFs(fsx.FromIOFS(web.Assets), "assets/core"),
)
appsFS := fsx.NewReadOnlyFs(
fsx.NewFallbackFS(
fsx.NewBasePathFs(fsx.NewOsFs(), options.Config.Asset.AppsPath),
fsx.NewBasePathFs(fsx.FromIOFS(web.Assets), "assets/apps"),
),
appsFS := fsx.NewFallbackFS(
fsx.NewReadOnlyFs(fsx.NewBasePathFs(fsx.NewOsFs(), options.Config.Asset.AppsPath)),
fsx.NewBasePathFs(fsx.FromIOFS(web.Assets), "assets/apps"),
)

// build and inject the list of applications into the config
for _, application := range apps.List(options.Logger, options.Config.Apps, coreFS.Primary().IOFS(), coreFS.Primary().IOFS()) {
for _, application := range apps.List(options.Logger, options.Config.Apps, appsFS.Secondary().IOFS(), appsFS.Primary().IOFS()) {
options.Config.Web.Config.ExternalApps = append(
options.Config.Web.Config.ExternalApps,
application.ToExternal(path.Join(options.Config.HTTP.Root, _customAppsEndpoint)),
Expand Down
15 changes: 13 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ sonar.go.coverage.reportPaths=cache/coverage/*
sonar.go.golangci-lint.reportPaths=cache/checkstyle/checkstyle.xml

# Exclude files
sonar.exclusions=**/third_party,docs/**,changelog/**,**/package.json,**/rollup.config.js,CHANGELOG.md,deployments/**,tests/**,vendor/**,vendor-bin/**,README.md,**/mocks/**,/protogen/**,services/search/pkg/query/kql/dictionary_gen.go
sonar.coverage.exclusions=**/*_test.go,**mocks/**,/protogen/**,services/search/pkg/query/kql/dictionary_gen.go
sonar.exclusions=**/third_party,docs/**,changelog/**,**/package.json,**/rollup.config.js,CHANGELOG.md,deployments/**,tests/**,vendor/**,vendor-bin/**,README.md,**/mocks/**,/protogen/**,**/*_gen.go
sonar.coverage.exclusions=**/*_test.go,**mocks/**,/protogen/**,**/*_gen.go
sonar.cpd.exclusions=**/*_test.go,**/revaconfig/**,services/settings/pkg/store/defaults/defaults.go

# Rule exclusions
sonar.issue.ignore.multicriteria=g1,g2

# Ignore "Define a constant instead of duplicating this literal" rule for tests
sonar.issue.ignore.multicriteria.g1.ruleKey=go:S1192
sonar.issue.ignore.multicriteria.g1.resourceKey=**/*_test.go

# Ignore "Rename function XXX to match the regular expression ^(_|[a-zA-Z0-9]+)$" rule for tests
sonar.issue.ignore.multicriteria.g2.ruleKey=go:S100
sonar.issue.ignore.multicriteria.g2.resourceKey=**/*_test.go

0 comments on commit a6277e7

Please sign in to comment.