Method Store.Export
has a Cognitive Complexity of 98 (exceeds 20 allowed). Consider refactoring. Open
func (store *Store) Export(filename string) (err error) {
backup := storeExport{}
if c, err := store.CustomTemplate().ReadAll(); err != nil {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Store.Export
has 178 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (store *Store) Export(filename string) (err error) {
backup := storeExport{}
if c, err := store.CustomTemplate().ReadAll(); err != nil {
Method Store.initServices
has 142 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (store *Store) initServices() error {
authorizationsetService, err := role.NewService(store.connection)
if err != nil {
return err
}
File services.go
has 568 lines of code (exceeds 500 allowed). Consider refactoring. Open
package datastore
import (
"fmt"
"os"
Store
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
type Store struct {
connection portainer.Connection
fileService portainer.FileService
CustomTemplateService *customtemplate.Service
Method Store.initServices
has 29 return statements (exceeds 4 allowed). Open
func (store *Store) initServices() error {
authorizationsetService, err := role.NewService(store.connection)
if err != nil {
return err
}
Method Store.Import
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (store *Store) Import(filename string) (err error) {
backup := storeExport{}
s, err := os.ReadFile(filename)
if err != nil {
Method Store.initServices
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (store *Store) initServices() error {
authorizationsetService, err := role.NewService(store.connection)
if err != nil {
return err
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Store.Import
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (store *Store) Import(filename string) (err error) {
backup := storeExport{}
s, err := os.ReadFile(filename)
if err != nil {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"