Skip to content

fix variable assigned and not used. #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2016

Conversation

appleboy
Copy link
Member

@appleboy appleboy commented Nov 15, 2016

Remove some variable assigned and not used.

ref: https://goreportcard.com/report/github.com/go-gitea/gitea#ineffassign

Signed-off-by: Bo-Yi Wu appleboy.tw@gmail.com

@codecov-io
Copy link

codecov-io commented Nov 15, 2016

Current coverage is 3.03% (diff: 0.00%)

Merging #173 into master will decrease coverage by <.01%

@@            master      #173   diff @@
========================================
  Files           33        33          
  Lines         8075      8096    +21   
  Methods          0         0          
  Messages         0         0          
  Branches         0         0          
========================================
  Hits           246       246          
- Misses        7809      7830    +21   
  Partials        20        20          

Powered by Codecov. Last update 07a0753...d9ffe99

@lunny
Copy link
Member

lunny commented Nov 15, 2016

This is really need a test.

@appleboy
Copy link
Member Author

@lunny There is no testing before make this PR. I just fix some error from goreport card service.

fmt.Sprintf("ForkRepository(git clone): %s/%s", u.Name, repo.Name),
"git", "clone", "--bare", oldRepo.RepoPath(), repoPath)
if err != nil {
return nil, fmt.Errorf("git clone: %v", stderr)
return nil, fmt.Errorf("git clone: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you have changed the functionality

@@ -2088,14 +2088,14 @@ func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Reposit
}

repoPath := RepoPath(u.Name, repo.Name)
_, stderr, err := process.ExecTimeout(10*time.Minute,
_, _, err = process.ExecTimeout(10*time.Minute,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stderr is used in that case

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@appleboy
Copy link
Member Author

@tboerger I changed process.ExecDir error behavior to make sure output log same with process.ExecTimeout.

@@ -2099,7 +2099,7 @@ func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Reposit
repoPath, fmt.Sprintf("ForkRepository(git update-server-info): %s", repoPath),
"git", "update-server-info")
if err != nil {
return nil, fmt.Errorf("git update-server-info: %v", err)
return nil, fmt.Errorf("git update-server-info: %v", stderr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition to print is err being not nil, so why printing stderr instead ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured, it's just process.ExecDir in modules/process/manager.go that would need a somewhat extended documentation. All returns are in the form:

  • return "", err.Error(), err
  • return "", ErrExecTimeout.Error(), ErrExecTimeout
  • return bufOut.String(), bufErr.String(), err

where the err variable in the last case is a return from cmd.Wait (exec.ExitError) while bufErr.String() is the stderr.

So the signature of ExecDir has a duplicated return value, because the "stderr" part is always included in the "err".
I suggest ExecDir signature is changed, to reduce confusion.

Copy link
Member

@strk strk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor ExecDir to drop the redundant return value

@@ -2099,7 +2099,7 @@ func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Reposit
repoPath, fmt.Sprintf("ForkRepository(git update-server-info): %s", repoPath),
"git", "update-server-info")
if err != nil {
return nil, fmt.Errorf("git update-server-info: %v", err)
return nil, fmt.Errorf("git update-server-info: %v", stderr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured, it's just process.ExecDir in modules/process/manager.go that would need a somewhat extended documentation. All returns are in the form:

  • return "", err.Error(), err
  • return "", ErrExecTimeout.Error(), ErrExecTimeout
  • return bufOut.String(), bufErr.String(), err

where the err variable in the last case is a return from cmd.Wait (exec.ExitError) while bufErr.String() is the stderr.

So the signature of ExecDir has a duplicated return value, because the "stderr" part is always included in the "err".
I suggest ExecDir signature is changed, to reduce confusion.

@tboerger
Copy link
Member

Refactoring is not part of this pr, I'm fine with this change. LGTM

@strk
Copy link
Member

strk commented Nov 15, 2016

Ok agreed, let's deal with refactoring somewhere else. LGTM.

@tboerger tboerger merged commit 56a8cf5 into go-gitea:master Nov 15, 2016
@tboerger tboerger added the type/enhancement An improvement of existing functionality label Nov 15, 2016
@tboerger tboerger added this to the 1.0.0 milestone Nov 15, 2016
@appleboy appleboy deleted the ineffassign98 branch November 15, 2016 07:22
ethantkoenig pushed a commit to ethantkoenig/gitea that referenced this pull request May 30, 2017
…gitea#174)

* Restores the HashTag code in Issue comments

* Has travis test with 1.7 and 1.8 of Go
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants