nikoksr/proji

View on GitHub

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
    }
Severity: Minor
Found in pkg/package/store/store.go - About 1 hr to fix

    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...]",
    Severity: Minor
    Found in cmd/projectRm.go - About 1 hr to fix

    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{
    Severity: Minor
    Found in cmd/packageExport.go - About 1 hr to fix

    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{
    Severity: Minor
    Found in cmd/packageExport.go - About 1 hr to fix

      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...]",
      Severity: Minor
      Found in cmd/packageImport.go - About 1 hr to fix

        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")
            }
        Severity: Major
        Found in pkg/package/service/dirstructure.go - About 55 mins to fix

          Function newPackageExportCommand has 9 return statements (exceeds 4 allowed).
          Open

          func newPackageExportCommand() *packageExportCommand {
              var exportAll, template bool
              var destination string
          
              cmd := &cobra.Command{
          Severity: Major
          Found in cmd/packageExport.go - About 55 mins to fix

            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)
            Severity: Major
            Found in cmd/packageEdit.go - About 50 mins to fix

              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
              Severity: Major
              Found in pkg/template_engine/template_engine.go - About 45 mins to fix

                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
                Severity: Major
                Found in pkg/package/store/store.go - About 45 mins to fix

                  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()
                  Severity: Major
                  Found in pkg/package/store/store.go - About 40 mins to fix

                    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
                        }
                    Severity: Major
                    Found in pkg/remote/github/repo.go - About 40 mins to fix

                      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")
                      Severity: Major
                      Found in pkg/project/service/create.go - About 40 mins to fix

                        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())
                            }
                        
                        
                        Severity: Major
                        Found in pkg/remote/github/github.go - About 40 mins to fix

                          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...]",
                          Severity: Minor
                          Found in cmd/packageRm.go - About 35 mins to fix

                          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...]",
                          Severity: Major
                          Found in cmd/projectRm.go - About 35 mins to fix

                            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")
                            Severity: Major
                            Found in pkg/package/service/remote.go - About 35 mins to fix

                              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"},
                              Severity: Major
                              Found in cmd/projectAdd.go - About 35 mins to fix

                                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"},
                                Severity: Major
                                Found in cmd/projectSetPath.go - About 35 mins to fix

                                  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...]",
                                  Severity: Major
                                  Found in cmd/packageImport.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language