nikoksr/proji

View on GitHub

Showing 37 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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    func (s Service) GetCollectionConfigs(url *url.URL, exclude *regexp.Regexp) ([]string, error) {
        // Setup repo
        repo, err := s.getRepository(url)
        if err != nil {
            return []string{}, errors.Wrap(err, "github service")
    Severity: Major
    Found in pkg/remote/github/github.go and 1 other location - About 1 hr to fix
    pkg/remote/gitlab/gitlab.go on lines 138..153

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 144.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    func (s Service) GetCollectionConfigs(url *url.URL, exclude *regexp.Regexp) ([]string, error) {
        // Setup repo
        repo, err := s.getRepository(url)
        if err != nil {
            return []string{}, errors.Wrap(err, "github service")
    Severity: Major
    Found in pkg/remote/gitlab/gitlab.go and 1 other location - About 1 hr to fix
    pkg/remote/github/github.go on lines 183..198

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 144.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    func (r repo) downloadPackageConfig(destination string, source *url.URL) (string, error) {
        // Extract file name
        fileName := filepath.Base(source.Path)
    
        // download file to temporary directory
    Severity: Major
    Found in pkg/remote/gitlab/gitlab.go and 1 other location - About 1 hr to fix
    pkg/remote/github/github.go on lines 210..224

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 143.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    func (r repo) downloadPackageConfig(destination string, source *url.URL) (string, error) {
        // Extract file name
        fileName := filepath.Base(source.Path)
    
        // download file to temporary directory
    Severity: Major
    Found in pkg/remote/github/github.go and 1 other location - About 1 hr to fix
    pkg/remote/gitlab/gitlab.go on lines 157..171

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 143.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    func (s Service) GetPackageConfig(url *url.URL) (string, error) {
        repo, err := s.getRepository(url)
        if err != nil {
            return "", errors.Wrap(err, "github service")
        }
    Severity: Major
    Found in pkg/remote/github/github.go and 1 other location - About 1 hr to fix
    pkg/remote/gitlab/gitlab.go on lines 124..136

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 138.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    func (s Service) GetPackageConfig(url *url.URL) (string, error) {
        repo, err := s.getRepository(url)
        if err != nil {
            return "", errors.Wrap(err, "github service")
        }
    Severity: Major
    Found in pkg/remote/gitlab/gitlab.go and 1 other location - About 1 hr to fix
    pkg/remote/github/github.go on lines 142..154

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 138.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        func newProjectListCommand() *projectListCommand {
            cmd := &cobra.Command{
                Use:                   "ls",
                Short:                 "List projects",
                Aliases:               []string{"l"},
        Severity: Major
        Found in cmd/projectLs.go and 2 other locations - About 55 mins to fix
        cmd/packageLs.go on lines 16..28
        cmd/projectClean.go on lines 14..26

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 126.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        func newPackageListCommand() *packageListCommand {
            cmd := &cobra.Command{
                Use:                   "ls",
                Short:                 "List packages",
                Aliases:               []string{"l"},
        Severity: Major
        Found in cmd/packageLs.go and 2 other locations - About 55 mins to fix
        cmd/projectClean.go on lines 14..26
        cmd/projectLs.go on lines 17..29

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 126.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        func newProjectCleanCommand() *projectCleanCommand {
            cmd := &cobra.Command{
                Use:                   "clean",
                Short:                 "Clean up projects",
                Aliases:               []string{"cln"},
        Severity: Major
        Found in cmd/projectClean.go and 2 other locations - About 55 mins to fix
        cmd/packageLs.go on lines 16..28
        cmd/projectLs.go on lines 17..29

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 126.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  func postRunPlugins(pluginsRootPath string, plugins []*domain.Plugin) error {
                      for _, plugin := range plugins {
                          if plugin.ExecNumber <= 0 {
                              continue
                          }
                  Severity: Minor
                  Found in pkg/project/service/create.go and 1 other location - About 40 mins to fix
                  pkg/project/service/create.go on lines 66..80

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 111.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language