Showing 26 of 37 total issues
Method packageStore.deepQueryPackage
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ps packageStore) deepQueryPackage(conditions string, values ...string) (pkg *domain.Package, err error) {
rows, err := ps.db.Raw(defaultPackageDeepQueryBase+" "+conditions, values).Rows()
if err != nil {
return nil, err
}
Function newProjectRemoveCommand
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func newProjectRemoveCommand() *projectRemoveCommand {
var removeAllProjects, forceRemoveProjects bool
cmd := &cobra.Command{
Use: "rm PATH [PATH...]",
- 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
Function newPackageExportCommand
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func newPackageExportCommand() *packageExportCommand {
var exportAll, template bool
var destination string
cmd := &cobra.Command{
- 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
Function newPackageExportCommand
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func newPackageExportCommand() *packageExportCommand {
var exportAll, template bool
var destination string
cmd := &cobra.Command{
Function newPackageImportCommand
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func newPackageImportCommand() *packageImportCommand {
var remoteRepos, directories, configs, packages, collections []string
cmd := &cobra.Command{
Use: "import FROM [FROM...]",
Method packageService.ImportPackageFromDirectoryStructure
has 9 return statements (exceeds 4 allowed). Open
func (ps packageService) ImportPackageFromDirectoryStructure(path string, exclude *regexp.Regexp) (*domain.Package, error) {
// Validate that the directory exists
if !util.DoesPathExist(path) {
return nil, fmt.Errorf("given directory does not exist")
}
Function newPackageExportCommand
has 9 return statements (exceeds 4 allowed). Open
func newPackageExportCommand() *packageExportCommand {
var exportAll, template bool
var destination string
cmd := &cobra.Command{
Function editPackageConfig
has 8 return statements (exceeds 4 allowed). Open
func editPackageConfig(packageLabel string) (err error) {
// Try to load the package; implicitly checks if a package is even associated to the given label.
pkg, err := session.packageService.LoadPackage(true, packageLabel)
if err != nil {
return fmt.Errorf("load package: %v", err)
Method TemplateEngine.parseTemplateFile
has 7 return statements (exceeds 4 allowed). Open
func (e *TemplateEngine) parseTemplateFile(path, destination string) error {
// Load the template file
b, err := ioutil.ReadFile(path)
if err != nil {
return err
Method packageStore.StorePackage
has 7 return statements (exceeds 4 allowed). Open
func (ps packageStore) StorePackage(pkg *domain.Package) error {
// Check if package exists
err := ps.db.Where("label = ?", pkg.Label).First(pkg).Error
if err == nil {
return ErrPackageExists
Method packageStore.RemovePackage
has 6 return statements (exceeds 4 allowed). Open
func (ps packageStore) RemovePackage(label string) error {
tx := ps.db.Begin()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
Method repo.setBranch
has 6 return statements (exceeds 4 allowed). Open
func (r *repo) setBranch(ctx context.Context, isAuthenticated bool) error {
// Skip if a branch was already set
if r.branch != "" {
return nil
}
Method projectService.CreateProject
has 6 return statements (exceeds 4 allowed). Open
func (ps projectService) CreateProject(configRootPath string, project *domain.Project) (err error) {
// Create the root folder of the project.
err = createProjectRootFolder(project.Path)
if err != nil {
return errors.Wrap(err, "create base folder")
Method Service.getRepository
has 6 return statements (exceeds 4 allowed). Open
func (s Service) getRepository(url *url.URL) (*repo, error) {
if url.Hostname() != "github.com" {
return nil, fmt.Errorf("invalid host %s", url.Hostname())
}
Function newPackageRemoveCommand
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func newPackageRemoveCommand() *packageRemoveCommand {
var removeAllPackages, forceRemovePackages bool
cmd := &cobra.Command{
Use: "rm LABEL [LABEL...]",
- 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
Function newProjectRemoveCommand
has 5 return statements (exceeds 4 allowed). Open
func newProjectRemoveCommand() *projectRemoveCommand {
var removeAllProjects, forceRemoveProjects bool
cmd := &cobra.Command{
Use: "rm PATH [PATH...]",
Method packageService.ImportPackageFromRemote
has 5 return statements (exceeds 4 allowed). Open
func (ps packageService) ImportPackageFromRemote(url *url.URL) (*domain.Package, error) {
// Get code repo
codeRepo, err := remote.NewCodeRepository(url, ps.authentication)
if err != nil {
return nil, errors.Wrap(err, "get code repository")
Function newProjectAddCommand
has 5 return statements (exceeds 4 allowed). Open
func newProjectAddCommand() *projectAddCommand {
cmd := &cobra.Command{
Use: "add LABEL PATH",
Short: "Add an existing project",
Aliases: []string{"a"},
Function newProjectSetPathCommand
has 5 return statements (exceeds 4 allowed). Open
func newProjectSetPathCommand() *projectSetPath {
cmd := &cobra.Command{
Use: "path OLD-PATH NEW-PATH",
Short: "Set a new path",
Aliases: []string{"p"},
Function newPackageImportCommand
has 5 return statements (exceeds 4 allowed). Open
func newPackageImportCommand() *packageImportCommand {
var remoteRepos, directories, configs, packages, collections []string
cmd := &cobra.Command{
Use: "import FROM [FROM...]",