zephinzer/dev

View on GitHub

Showing 57 of 79 total issues

Function run has 54 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func run(cmd *cobra.Command, args []string) {
    pathToInitialiseAt := path.Join(args...)
    log.Debug("resolving provided path %s...", pathToInitialiseAt)
    pathToInitialiseAt, resolvePathError := utils.ResolvePath(pathToInitialiseAt)
    if resolvePathError != nil {
Severity: Minor
Found in cmd/dev/initialise/repository/command.go - About 1 hr to fix

    Function Download has 11 return statements (exceeds 4 allowed).
    Open

    func Download(options DownloadOptions) error {
        downloadStatus := DownloadStatus{}
        tmpFilePath := options.FilePath + ".download_" + time.Now().Format("20060102150405")
        if options.Events == nil {
            options.Events = make(chan DownloadEvent, 16)
    Severity: Major
    Found in pkg/utils/network/download.go - About 1 hr to fix

      Function GetCommand has 52 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func GetCommand() *cobra.Command {
          cmd := cobra.Command{
              Use:     constants.NotificationsCanonicalNoun,
              Aliases: constants.NotificationsAliases,
              Short:   "Initialises telegram notifications",
      Severity: Minor
      Found in cmd/dev/initialise/telegram/notifications/command.go - About 1 hr to fix

        Function Init has 10 return statements (exceeds 4 allowed).
        Open

        func Init(atPath string) error {
            directory := filepath.Dir(atPath)
            filename := filepath.Base(atPath)
            fullPath := path.Join(directory, filename)
            fullPathInfo, checkFileError := os.Lstat(fullPath)
        Severity: Major
        Found in internal/db/init.go - About 1 hr to fix

          Function Unzip has 10 return statements (exceeds 4 allowed).
          Open

          func Unzip(options UnzipOptions) []error {
              var err error
              status := UnzipStatus{}
          
              if options.Events == nil {
          Severity: Major
          Found in pkg/utils/unzip.go - About 1 hr to fix

            Function run has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
            Open

            func run(command *cobra.Command, args []string) {
                if config.Global.Repositories == nil {
                    log.Error("no repositories have been defined")
                    os.Exit(1)
                    return
            Severity: Minor
            Found in cmd/dev/check/repositories/command.go - About 55 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 run has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
            Open

            func run(command *cobra.Command, args []string) {
                if len(args) == 0 {
                    command.Help()
                    log.Errorf("no repository url(s) specified, see usage above for how to use this command")
                    os.Exit(1)
            Severity: Minor
            Found in cmd/dev/add/repository/command.go - About 55 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 GetSSH has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
            Open

            func GetSSH(keysDirectory string) ([]Key, error) {
                directoryList, readDirError := ioutil.ReadDir(keysDirectory)
                if readDirError != nil {
                    return nil, fmt.Errorf("failed to list directory at '%s': %s", keysDirectory, readDirError)
                }
            Severity: Minor
            Found in pkg/utils/keys/ssh_keys.go - About 55 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 Untar has 9 return statements (exceeds 4 allowed).
            Open

            func Untar(options UntarOptions) []error {
                var err error
                status := UntarStatus{}
            
                if options.Events == nil {
            Severity: Major
            Found in pkg/utils/untar.go - About 55 mins to fix

              Function run has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
              Open

              func run(command *cobra.Command, args []string) {
                  targetWorkspaceName := strings.Join(args, ".")
                  if len(targetWorkspaceName) == 0 {
                      command.Help()
                      workspaces := c.Global.Repositories.GetWorkspaces()
              Severity: Minor
              Found in cmd/dev/get/workspace/command.go - About 55 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 getOAuthCallbackHandler has 8 return statements (exceeds 4 allowed).
              Open

              func getOAuthCallbackHandler(res http.ResponseWriter, req *http.Request) {
                  requestID := uuid.New().String()
              
                  params := mux.Vars(req)
              
              
              Severity: Major
              Found in cmd/dev/start/server/get_oauth_callback.go - About 50 mins to fix

                Function WatchNotifications has 7 return statements (exceeds 4 allowed).
                Open

                func WatchNotifications(
                    accounts []AccountConfig,
                    databaseConnection *sql.DB,
                    updateInterval time.Duration,
                    stop chan struct{},
                Severity: Major
                Found in internal/gitlab/watchers.go - About 45 mins to fix

                  Method Repository.GetPath has 7 return statements (exceeds 4 allowed).
                  Open

                  func (r Repository) GetPath(rootPath ...string) (string, error) {
                      // if :rootPath is defined, use that as the root instead of the current directory
                      storagePath := "."
                      if len(rootPath) > 0 {
                          storagePath = rootPath[0]
                  Severity: Major
                  Found in pkg/repository/repository.go - About 45 mins to fix

                    Method VSCode.WriteTo has 7 return statements (exceeds 4 allowed).
                    Open

                    func (vsc VSCode) WriteTo(workspacePath string, overwrite ...bool) error {
                        isOverwritable := false
                        if len(overwrite) > 0 {
                            isOverwritable = overwrite[0]
                        }
                    Severity: Major
                    Found in internal/workspace/vscode.go - About 45 mins to fix

                      Function Check has 7 return statements (exceeds 4 allowed).
                      Open

                      func Check(atPath string) error {
                          absolutePath, resolvePathError := utils.ResolvePath(atPath)
                          if resolvePathError != nil {
                              return fmt.Errorf("failed to resolve path '%s': %s", atPath, resolvePathError)
                          }
                      Severity: Major
                      Found in internal/db/check.go - About 45 mins to fix

                        Method GrantResponse.LoadFromJSON has 6 return statements (exceeds 4 allowed).
                        Open

                        func (r *GrantResponse) LoadFromJSON(responseBody []byte, mapping ...map[GrantResponseKey]string) error {
                            responseFieldMap := DefaultGrantResponseMapping
                            if len(mapping) > 0 {
                                responseFieldMap = mapping[0]
                            }
                        Severity: Major
                        Found in pkg/oauth/grant_response.go - About 40 mins to fix

                          Function GetRemote has 6 return statements (exceeds 4 allowed).
                          Open

                          func GetRemote(fromGitRepositoryAt string, remoteNameMatcher ...string) (*Remote, error) {
                              // validation checks
                              gitPath := path.Join(fromGitRepositoryAt, "/.git")
                              fileInfo, err := os.Lstat(gitPath)
                              if err != nil {
                          Severity: Major
                          Found in internal/git/remote.go - About 40 mins to fix

                            Method Repository.GetWebsiteURL has 6 return statements (exceeds 4 allowed).
                            Open

                            func (r Repository) GetWebsiteURL() (string, error) {
                                switch true {
                                case validator.IsGitHTTPUrl(r.URL):
                                    link, err := str.GetHttpLinkFromHttpCloneUrl(r.URL)
                                    if err != nil {
                            Severity: Major
                            Found in pkg/repository/repository.go - About 40 mins to fix

                              Function ToSelect has 6 return statements (exceeds 4 allowed).
                              Open

                              func ToSelect(options InputOptions) (int, error) {
                                  helper := InputHelper(options)
                                  fmt.Printf("\n")
                                  helper.PrintBeforeMessage()
                                  fmt.Printf("\n")
                              Severity: Major
                              Found in internal/prompt/select.go - About 40 mins to fix

                                Function ResolvePath has 6 return statements (exceeds 4 allowed).
                                Open

                                func ResolvePath(relativePathFragments ...string) (string, error) {
                                    fullPath := path.Join(relativePathFragments...)
                                    if len(fullPath) == 0 {
                                        fullPath = "."
                                    }
                                Severity: Major
                                Found in pkg/utils/paths.go - About 40 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language