aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2021-12-20 05:41:31 +0100
committerGitHub <noreply@github.com>2021-12-20 04:41:31 +0000
commitff2fd08228dd6323ac4a1cbd2f37f8ae15733eab (patch)
tree9079b869968d358502f64ce03caf4097556c53cd /services
parent25677cdc5b11f7100ca2e4b0819e02ca62e22ab1 (diff)
downloadgitea-ff2fd08228dd6323ac4a1cbd2f37f8ae15733eab.tar.gz
gitea-ff2fd08228dd6323ac4a1cbd2f37f8ae15733eab.zip
Simplify parameter types (#18006)
Remove repeated type declarations in function definitions.
Diffstat (limited to 'services')
-rw-r--r--services/attachment/attachment.go2
-rw-r--r--services/gitdiff/csv.go6
-rw-r--r--services/issue/assignee.go2
-rw-r--r--services/migrations/dump.go2
-rw-r--r--services/migrations/restore.go2
-rw-r--r--services/pull/review.go3
-rw-r--r--services/repository/files/temp_repo.go6
-rw-r--r--services/repository/files/update.go2
-rw-r--r--services/webhook/general.go4
-rw-r--r--services/webhook/matrix.go2
-rw-r--r--services/webhook/slack.go2
11 files changed, 16 insertions, 17 deletions
diff --git a/services/attachment/attachment.go b/services/attachment/attachment.go
index e3b65a239b..cce36206a7 100644
--- a/services/attachment/attachment.go
+++ b/services/attachment/attachment.go
@@ -40,7 +40,7 @@ func NewAttachment(attach *repo_model.Attachment, file io.Reader) (*repo_model.A
}
// UploadAttachment upload new attachment into storage and update database
-func UploadAttachment(file io.Reader, actorID, repoID, releaseID int64, fileName string, allowedTypes string) (*repo_model.Attachment, error) {
+func UploadAttachment(file io.Reader, actorID, repoID, releaseID int64, fileName, allowedTypes string) (*repo_model.Attachment, error) {
buf := make([]byte, 1024)
n, _ := util.ReadAtMost(file, buf)
buf = buf[:n]
diff --git a/services/gitdiff/csv.go b/services/gitdiff/csv.go
index 099660b172..0e56ff3150 100644
--- a/services/gitdiff/csv.go
+++ b/services/gitdiff/csv.go
@@ -111,7 +111,7 @@ func (csv *csvReader) readNextRow() ([]string, error) {
}
// CreateCsvDiff creates a tabular diff based on two CSV readers.
-func CreateCsvDiff(diffFile *DiffFile, baseReader *csv.Reader, headReader *csv.Reader) ([]*TableDiffSection, error) {
+func CreateCsvDiff(diffFile *DiffFile, baseReader, headReader *csv.Reader) ([]*TableDiffSection, error) {
if baseReader != nil && headReader != nil {
return createCsvDiff(diffFile, baseReader, headReader)
}
@@ -149,7 +149,7 @@ func createCsvDiffSingle(reader *csv.Reader, celltype TableDiffCellType) ([]*Tab
return []*TableDiffSection{{Rows: rows}}, nil
}
-func createCsvDiff(diffFile *DiffFile, baseReader *csv.Reader, headReader *csv.Reader) ([]*TableDiffSection, error) {
+func createCsvDiff(diffFile *DiffFile, baseReader, headReader *csv.Reader) ([]*TableDiffSection, error) {
// Given the baseReader and headReader, we are going to create CSV Reader for each, baseCSVReader and b respectively
baseCSVReader, err := createCsvReader(baseReader, maxRowsToInspect)
if err != nil {
@@ -346,7 +346,7 @@ func createCsvDiff(diffFile *DiffFile, baseReader *csv.Reader, headReader *csv.R
}
// getColumnMapping creates a mapping of columns between a and b
-func getColumnMapping(baseCSVReader *csvReader, headCSVReader *csvReader) ([]int, []int) {
+func getColumnMapping(baseCSVReader, headCSVReader *csvReader) ([]int, []int) {
baseRow, _ := baseCSVReader.GetRow(0)
headRow, _ := headCSVReader.GetRow(0)
diff --git a/services/issue/assignee.go b/services/issue/assignee.go
index 14c040ad7a..4fdf0029c8 100644
--- a/services/issue/assignee.go
+++ b/services/issue/assignee.go
@@ -57,7 +57,7 @@ func ToggleAssignee(issue *models.Issue, doer *user_model.User, assigneeID int64
}
// ReviewRequest add or remove a review request from a user for this PR, and make comment for it.
-func ReviewRequest(issue *models.Issue, doer *user_model.User, reviewer *user_model.User, isAdd bool) (comment *models.Comment, err error) {
+func ReviewRequest(issue *models.Issue, doer, reviewer *user_model.User, isAdd bool) (comment *models.Comment, err error) {
if isAdd {
comment, err = models.AddReviewRequest(issue, reviewer, doer)
} else {
diff --git a/services/migrations/dump.go b/services/migrations/dump.go
index afff49a059..1a8a3d296c 100644
--- a/services/migrations/dump.go
+++ b/services/migrations/dump.go
@@ -606,7 +606,7 @@ func updateOptionsUnits(opts *base.MigrateOptions, units []string) {
}
// RestoreRepository restore a repository from the disk directory
-func RestoreRepository(ctx context.Context, baseDir string, ownerName, repoName string, units []string) error {
+func RestoreRepository(ctx context.Context, baseDir, ownerName, repoName string, units []string) error {
doer, err := user_model.GetAdminUser()
if err != nil {
return err
diff --git a/services/migrations/restore.go b/services/migrations/restore.go
index 87e5316ef6..357e995423 100644
--- a/services/migrations/restore.go
+++ b/services/migrations/restore.go
@@ -26,7 +26,7 @@ type RepositoryRestorer struct {
}
// NewRepositoryRestorer creates a repository restorer which could restore repository from a dumped folder
-func NewRepositoryRestorer(ctx context.Context, baseDir string, owner, repoName string) (*RepositoryRestorer, error) {
+func NewRepositoryRestorer(ctx context.Context, baseDir, owner, repoName string) (*RepositoryRestorer, error) {
baseDir, err := filepath.Abs(baseDir)
if err != nil {
return nil, err
diff --git a/services/pull/review.go b/services/pull/review.go
index 3f2e4bdf5f..42292ac209 100644
--- a/services/pull/review.go
+++ b/services/pull/review.go
@@ -22,8 +22,7 @@ import (
)
// CreateCodeComment creates a comment on the code line
-func CreateCodeComment(doer *user_model.User, gitRepo *git.Repository, issue *models.Issue, line int64, content string, treePath string, isReview bool, replyReviewID int64, latestCommitID string) (*models.Comment, error) {
-
+func CreateCodeComment(doer *user_model.User, gitRepo *git.Repository, issue *models.Issue, line int64, content, treePath string, isReview bool, replyReviewID int64, latestCommitID string) (*models.Comment, error) {
var (
existsReview bool
err error
diff --git a/services/repository/files/temp_repo.go b/services/repository/files/temp_repo.go
index 52879dd3b0..bc761e3101 100644
--- a/services/repository/files/temp_repo.go
+++ b/services/repository/files/temp_repo.go
@@ -188,12 +188,12 @@ func (t *TemporaryUploadRepository) GetLastCommitByRef(ref string) (string, erro
}
// CommitTree creates a commit from a given tree for the user with provided message
-func (t *TemporaryUploadRepository) CommitTree(author, committer *user_model.User, treeHash string, message string, signoff bool) (string, error) {
+func (t *TemporaryUploadRepository) CommitTree(author, committer *user_model.User, treeHash, message string, signoff bool) (string, error) {
return t.CommitTreeWithDate(author, committer, treeHash, message, signoff, time.Now(), time.Now())
}
// CommitTreeWithDate creates a commit from a given tree for the user with provided message
-func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *user_model.User, treeHash string, message string, signoff bool, authorDate, committerDate time.Time) (string, error) {
+func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *user_model.User, treeHash, message string, signoff bool, authorDate, committerDate time.Time) (string, error) {
authorSig := author.NewGitSig()
committerSig := committer.NewGitSig()
@@ -263,7 +263,7 @@ func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *user_m
}
// Push the provided commitHash to the repository branch by the provided user
-func (t *TemporaryUploadRepository) Push(doer *user_model.User, commitHash string, branch string) error {
+func (t *TemporaryUploadRepository) Push(doer *user_model.User, commitHash, branch string) error {
// Because calls hooks we need to pass in the environment
env := models.PushingEnvironment(doer, t.repo)
if err := git.Push(t.gitRepo.Ctx, t.basePath, git.PushOptions{
diff --git a/services/repository/files/update.go b/services/repository/files/update.go
index 4bafa62cc1..0e012e16bc 100644
--- a/services/repository/files/update.go
+++ b/services/repository/files/update.go
@@ -442,7 +442,7 @@ func CreateOrUpdateRepoFile(repo *repo_model.Repository, doer *user_model.User,
}
// VerifyBranchProtection verify the branch protection for modifying the given treePath on the given branch
-func VerifyBranchProtection(repo *repo_model.Repository, doer *user_model.User, branchName string, treePath string) error {
+func VerifyBranchProtection(repo *repo_model.Repository, doer *user_model.User, branchName, treePath string) error {
protectedBranch, err := models.GetProtectedBranchBy(repo.ID, branchName)
if err != nil {
return err
diff --git a/services/webhook/general.go b/services/webhook/general.go
index 32a79c0783..5080cf98dc 100644
--- a/services/webhook/general.go
+++ b/services/webhook/general.go
@@ -18,12 +18,12 @@ import (
type linkFormatter = func(string, string) string
// noneLinkFormatter does not create a link but just returns the text
-func noneLinkFormatter(url string, text string) string {
+func noneLinkFormatter(url, text string) string {
return text
}
// htmlLinkFormatter creates a HTML link
-func htmlLinkFormatter(url string, text string) string {
+func htmlLinkFormatter(url, text string) string {
return fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(url), html.EscapeString(text))
}
diff --git a/services/webhook/matrix.go b/services/webhook/matrix.go
index 4fd78ff5bb..72392debe9 100644
--- a/services/webhook/matrix.go
+++ b/services/webhook/matrix.go
@@ -87,7 +87,7 @@ func (m *MatrixPayloadUnsafe) JSONPayload() ([]byte, error) {
}
// MatrixLinkFormatter creates a link compatible with Matrix
-func MatrixLinkFormatter(url string, text string) string {
+func MatrixLinkFormatter(url, text string) string {
return fmt.Sprintf(`<a href="%s">%s</a>`, html.EscapeString(url), html.EscapeString(text))
}
diff --git a/services/webhook/slack.go b/services/webhook/slack.go
index 575aedf0c0..a67fe6a762 100644
--- a/services/webhook/slack.go
+++ b/services/webhook/slack.go
@@ -85,7 +85,7 @@ func SlackShortTextFormatter(s string) string {
}
// SlackLinkFormatter creates a link compatible with slack
-func SlackLinkFormatter(url string, text string) string {
+func SlackLinkFormatter(url, text string) string {
return fmt.Sprintf("<%s|%s>", url, SlackTextFormatter(text))
}