Fix lint and typos

This commit is contained in:
HairyFotr
2017-08-08 20:27:30 +02:00
parent d8e0a06d93
commit 0149593272
30 changed files with 57 additions and 58 deletions

View File

@@ -1,4 +1,4 @@
### Before submitting an issue to Gitbucket I have first:
### Before submitting an issue to GitBucket I have first:
- [] read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
- [] searched for similar already existing issue
@@ -9,7 +9,7 @@
## Issue
**Impacted version**: xxxx
**Deployment mode**: *explain here how you use gitbucket : standalone app, under webcontainer (which one), with an http frontend (nginx, httpd, ...)*
**Deployment mode**: *explain here how you use GitBucket : standalone app, under webcontainer (which one), with an http frontend (nginx, httpd, ...)*
**Problem description**:
- *be as explicit has you can*

View File

@@ -1,4 +1,4 @@
### Before submitting a pull-request to Gitbucket I have first:
### Before submitting a pull-request to GitBucket I have first:
- [] read the [contribution guidelines](https://github.com/gitbucket/gitbucket/blob/master/.github/CONTRIBUTING.md)
- [] rebased my branch over master

View File

@@ -59,7 +59,7 @@ GitBucket has a plug-in system that allows extra functionality. Officially the f
- [gitbucket-pages-plugin](https://github.com/gitbucket/gitbucket-pages-plugin)
- [gitbucket-notifications-plugin](https://github.com/gitbucket/gitbucket-notifications-plugin)
You can find more plugins made by the community at [GitBucket community plugins](http://gitbucket-plugins.github.io/).
You can find more plugins made by the community at [GitBucket community plugins](https://gitbucket-plugins.github.io/).
Support
--------

View File

@@ -1,7 +1,7 @@
JRebel integration (optional)
=============================
[JRebel](http://zeroturnaround.com/software/jrebel/) is a JVM plugin that makes developing web apps much faster.
[JRebel](https://zeroturnaround.com/software/jrebel/) is a JVM plugin that makes developing web apps much faster.
JRebel is generally able to eliminate the need for the following slow "app restart" in sbt following a code change:
```
@@ -22,12 +22,12 @@ Sign up for a [usage plan](https://my.jrebel.com/). You will need to create an a
## 2. Download JRebel
Download the most recent ["nosetup" JRebel zip](http://zeroturnaround.com/software/jrebel/download/prev-releases/).
Download the most recent ["nosetup" JRebel zip](https://zeroturnaround.com/software/jrebel/download/prev-releases/).
Next, unzip the downloaded file.
## 3. Activate
Follow the [instructions on the JRebel website](http://zeroturnaround.com/software/jrebel/download/prev-releases/) to activate your downloaded JRebel.
Follow the [instructions on the JRebel website](https://zeroturnaround.com/software/jrebel/download/prev-releases/) to activate your downloaded JRebel.
You can use the default settings for all the configurations.

View File

@@ -381,7 +381,7 @@ trait ApiControllerBase extends ControllerBase {
get("/api/v3/repos/:owner/:repository/issues/:id/comments")(referrersOnly { repository =>
(for{
issueId <- params("id").toIntOpt
comments = getCommentsForApi(repository.owner, repository.name, issueId.toInt)
comments = getCommentsForApi(repository.owner, repository.name, issueId)
} yield {
JsonFormat(comments.map{ case (issueComment, user, issue) => ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest) })
}) getOrElse NotFound()

View File

@@ -163,7 +163,7 @@ abstract class ControllerBase extends ScalatraFilter
override def validate(name: String, value: String, params: Map[String, String], messages: Messages): Seq[(String, String)] =
valueType.validate(name, trim(value), params, messages)
private def trim(value: String): String = if(value == null) null else value.replaceAll("\r\n", "").trim
private def trim(value: String): String = if(value == null) null else value.replace("\r\n", "").trim
}
/**

View File

@@ -213,7 +213,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
post("/:owner/:repository/upload", uploadForm)(writableUsersOnly { (form, repository) =>
val files = form.uploadFiles.split("\n").map { line =>
val i = line.indexOf(":")
val i = line.indexOf(':')
CommitFile(line.substring(0, i).trim, line.substring(i + 1).trim)
}
@@ -222,7 +222,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
branch = form.branch,
path = form.path,
files = files,
message = form.message.getOrElse(s"Add files via upload")
message = form.message.getOrElse("Add files via upload")
)
if(form.path.length == 0){
@@ -630,8 +630,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
}
})
case class UploadFiles(branch: String, path: String, fileIds : Map[String,String], message: String) {
lazy val isValid: Boolean = fileIds.size > 0
case class UploadFiles(branch: String, path: String, fileIds: Map[String,String], message: String) {
lazy val isValid: Boolean = fileIds.nonEmpty
}
case class CommitFile(id: String, name: String)

View File

@@ -503,14 +503,14 @@ object IssuesService {
).flatten ++
labels.map(label => s"label:${label}") ++
List(
milestone.map { _ match {
milestone.map {
case Some(x) => s"milestone:${x}"
case None => "no:milestone"
}},
priority.map { _ match {
},
priority.map {
case Some(x) => s"priority:${x}"
case None => "no:priority"
}},
},
(sort, direction) match {
case ("created" , "desc") => None
case ("created" , "asc" ) => Some("sort:created-asc")

View File

@@ -18,10 +18,11 @@ trait ProtectedBranchService {
.filter(_._1.byPrimaryKey(owner, repository, branch))
.list
.groupBy(_._1)
.headOption
.map { p => p._1 -> p._2.flatMap(_._2) }
.map { case (t1, contexts) =>
new ProtectedBranchInfo(t1.userName, t1.repositoryName, true, contexts, t1.statusCheckAdmin)
}.headOption
}
def getProtectedBranchInfo(owner: String, repository: String, branch: String)(implicit session: Session): ProtectedBranchInfo =
getProtectedBranchInfoOpt(owner, repository, branch).getOrElse(ProtectedBranchInfo.disabled(owner, repository))

View File

@@ -94,9 +94,9 @@ trait PullRequestService { self: IssuesService with CommitsService =>
/**
* for repository viewer.
* 1. find pull request from from `branch` to othre branch on same repository
* 1. find pull request from `branch` to other branch on same repository
* 1. return if exists pull request to `defaultBranch`
* 2. return if exists pull request to othre branch
* 2. return if exists pull request to other branch
* 2. return None
*/
def getPullRequestFromBranch(userName: String, repositoryName: String, branch: String, defaultBranch: String)
@@ -256,7 +256,7 @@ object PullRequestService {
val statuses: List[CommitStatus] =
commitStatues ++ (branchProtection.contexts.toSet -- commitStatues.map(_.context).toSet).map(CommitStatus.pending(branchProtection.owner, branchProtection.repository, _))
val hasRequiredStatusProblem = needStatusCheck && branchProtection.contexts.exists(context => statuses.find(_.context == context).map(_.state) != Some(CommitState.SUCCESS))
val hasProblem = hasRequiredStatusProblem || hasConflict || (!statuses.isEmpty && CommitState.combine(statuses.map(_.state).toSet) != CommitState.SUCCESS)
val hasProblem = hasRequiredStatusProblem || hasConflict || (statuses.nonEmpty && CommitState.combine(statuses.map(_.state).toSet) != CommitState.SUCCESS)
val canUpdate = branchIsOutOfDate && !hasConflict
val canMerge = hasMergePermission && !hasConflict && !hasRequiredStatusProblem
lazy val commitStateSummary:(CommitState, String) = {

View File

@@ -67,7 +67,7 @@ trait RepositorySearchService { self: IssuesService =>
files.map { case (path, text) =>
val (highlightText, lineNumber) = getHighlightText(text, query)
FileSearchResult(
path.replaceFirst("\\.md$", ""),
path.stripSuffix(".md"),
commits(path).getCommitterIdent.getWhen,
highlightText,
lineNumber)

View File

@@ -135,7 +135,7 @@ trait RepositoryService { self: AccountService =>
repositoryName = newRepositoryName
)) :_*)
// TODO Drop transfered owner from collaborators?
// TODO Drop transferred owner from collaborators?
Collaborators.insertAll(collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
// Update activity messages

View File

@@ -367,9 +367,9 @@ object WebHookService {
repository: ApiRepository
) extends FieldSerializable with WebHookPayload {
val compare = commits.size match {
case 0 => ApiPath(s"/${repository.full_name}") // maybe test hook on un-initalied repository
case 0 => ApiPath(s"/${repository.full_name}") // maybe test hook on un-initialized repository
case 1 => ApiPath(s"/${repository.full_name}/commit/${after}")
case _ if before.filterNot(_=='0').isEmpty => ApiPath(s"/${repository.full_name}/compare/${commits.head.id}^...${after}")
case _ if before.forall(_=='0') => ApiPath(s"/${repository.full_name}/compare/${commits.head.id}^...${after}")
case _ => ApiPath(s"/${repository.full_name}/compare/${before}...${after}")
}
val head_commit = commits.lastOption

View File

@@ -237,7 +237,7 @@ trait WikiService {
builder.finish()
val newHeadId = JGitUtil.createNewCommit(git, inserter, headId, builder.getDirCache.writeTree(inserter),
Constants.HEAD, committer.fullName, committer.mailAddress,
if(message.trim.length == 0) {
if(message.trim.isEmpty) {
if(removed){
s"Rename ${currentPageName} to ${newPageName}"
} else if(created){

View File

@@ -74,7 +74,7 @@ class GitAuthenticationFilter extends Filter with RepositoryService with Account
val action = request.paths match {
case Array(_, repositoryOwner, repositoryName, _*) =>
Database() withSession { implicit session =>
getRepository(repositoryOwner, repositoryName.replaceFirst("\\.wiki\\.git$|\\.git$", "")) match {
getRepository(repositoryOwner, repositoryName.replaceFirst("(\\.wiki)?\\.git$", "")) match {
case Some(repository) => {
val execute = if (!isUpdating && !repository.repository.isPrivate && settings.allowAnonymousAccess) {
// Authentication is not required

View File

@@ -166,7 +166,7 @@ class GitBucketReceivePackFactory extends ReceivePackFactory[HttpServletRequest]
if(repository.endsWith(".wiki")){
defining(request) { implicit r =>
receivePack.setPostReceiveHook(new WikiCommitHook(owner, repository.replaceFirst("\\.wiki$", ""), pusher, baseUrl))
receivePack.setPostReceiveHook(new WikiCommitHook(owner, repository.stripSuffix(".wiki"), pusher, baseUrl))
}
}
}

View File

@@ -19,7 +19,7 @@ class PluginAssetsServlet extends HttpServlet {
.find { case (prefix, _, _) => path.startsWith("/plugin-assets" + prefix) }
.flatMap { case (prefix, resourcePath, classLoader) =>
val resourceName = path.substring(("/plugin-assets" + prefix).length)
Option(classLoader.getResourceAsStream(resourcePath.replaceFirst("^/", "") + resourceName))
Option(classLoader.getResourceAsStream(resourcePath.stripPrefix("/") + resourceName))
}
.map { in =>
try {

View File

@@ -6,7 +6,7 @@ import javax.servlet.{ServletContextEvent, ServletContextListener}
import gitbucket.core.service.SystemSettingsService
import gitbucket.core.service.SystemSettingsService.SshAddress
import gitbucket.core.util.{Directory}
import gitbucket.core.util.Directory
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider
import org.slf4j.LoggerFactory

View File

@@ -75,7 +75,7 @@ object JDBCUtil {
var stringLiteral = false
while({ length = in.read(bytes); length != -1 }){
for(i <- 0 to length - 1){
for(i <- 0 until length){
val c = bytes(i)
if(c == '\''){
stringLiteral = !stringLiteral
@@ -146,14 +146,12 @@ object JDBCUtil {
}
}
val columnValues = values.map { value =>
value match {
val columnValues = values.map {
case x: String => "'" + x.replace("'", "''") + "'"
case x: Timestamp => "'" + dateFormat.format(x) + "'"
case null => "NULL"
case x => x
}
}
sb.append(columnValues.mkString(", "))
sb.append(");\n")
}

View File

@@ -93,7 +93,7 @@ object JGitUtil {
val summary = getSummaryMessage(fullMessage, shortMessage)
val description = defining(fullMessage.trim.indexOf("\n")){ i =>
val description = defining(fullMessage.trim.indexOf('\n')){ i =>
if(i >= 0){
Some(fullMessage.trim.substring(i).trim)
} else None
@@ -293,7 +293,7 @@ object JGitUtil {
@tailrec
def findLastCommits(result:List[(ObjectId, FileMode, String, String, Option[String], RevCommit)],
restList:List[((ObjectId, FileMode, String, String, Option[String]), Map[RevCommit, RevCommit])],
revIterator:java.util.Iterator[RevCommit]): List[(ObjectId, FileMode, String, String, Option[String], RevCommit)] ={
revIterator:java.util.Iterator[RevCommit]): List[(ObjectId, FileMode, String, String, Option[String], RevCommit)] = {
if(restList.isEmpty){
result
} else if(!revIterator.hasNext){ // maybe, revCommit has only 1 log. other case, restList be empty
@@ -366,7 +366,7 @@ object JGitUtil {
case (false, true ) => false
case _ => file1.name.compareTo(file2.name) < 0
}
}.toList
}
}
}
@@ -374,7 +374,7 @@ object JGitUtil {
* Returns the first line of the commit message.
*/
private def getSummaryMessage(fullMessage: String, shortMessage: String): String = {
defining(fullMessage.trim.indexOf("\n")){ i =>
defining(fullMessage.trim.indexOf('\n')){ i =>
defining(if(i >= 0) fullMessage.trim.substring(0, i).trim else fullMessage){ firstLine =>
if(firstLine.length > shortMessage.length) shortMessage else firstLine
}

View File

@@ -128,7 +128,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
repository: RepositoryService.RepositoryInfo,
enableWikiLink: Boolean, enableRefsLink: Boolean, enableAnchor: Boolean)(implicit context: Context): Html = {
val fileName = filePath.reverse.head.toLowerCase
val fileName = filePath.last.toLowerCase
val extension = FileUtil.getExtension(fileName)
val renderer = PluginRegistry().getRenderer(extension)
renderer.render(RenderRequest(filePath, fileContent, branch, repository, enableWikiLink, enableRefsLink, enableAnchor, context))

View File

@@ -18,7 +18,7 @@
if (document.queryCommandSupported('copy')) {
var title = $('#@copyButtonId').attr('title');
$('#@copyButtonId').tooltip({
@* if default container is used then 2 lines tooltip text is displayd because tooptip width is narrow. *@
@* if default container is used then 2 lines tooltip text is displayed because tooptip width is narrow. *@
container: 'body'
});
$('#@copyButtonId').on('click', function() {

View File

@@ -2,10 +2,10 @@
@import gitbucket.core.view.helpers
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US">
<id>tag:@context.host,2013:gitbucket</id>
<title>Gitbucket's activities</title>
<title>GitBucket's activities</title>
<link type="application/atom+xml" rel="self" href="@context.baseUrl/activities.atom"/>
<author>
<name>Gitbucket</name>
<name>GitBucket</name>
<uri>@context.baseUrl</uri>
</author>
<updated>@helpers.datetimeRFC3339(if(activities.isEmpty) new java.util.Date else activities.map(_.activityDate).max)</updated>

View File

@@ -71,7 +71,7 @@
</div>
</div>
@if(content.viewType == "text"){
@defining(helpers.isRenderable(pathList.reverse.head)){ isRenderable =>
@defining(helpers.isRenderable(pathList.last)){ isRenderable =>
@if(!isBlame && isRenderable) {
<div class="box-content-bottom markdown-body" style="padding-left: 20px; padding-right: 20px;">
@helpers.renderMarkup(pathList, content.content.get, branch, repository, false, false, true)

View File

@@ -175,7 +175,7 @@
</table>
@readme.map { case(filePath, content) =>
<div id="readme" class="panel panel-default">
<div class="panel-heading strong">@filePath.reverse.head</div>
<div class="panel-heading strong">@filePath.last</div>
<div class="panel-body markdown-body" style="padding-left: 20px; padding-right: 20px;">@helpers.renderMarkup(filePath, content, branch, repository, false, false, true)</div>
</div>
}

View File

@@ -12,7 +12,7 @@
</tr>
</thead>
<tbody>
@repository.tags.reverse.map { tag =>
@repository.tags.reverseMap { tag =>
<tr>
<td><a href="@helpers.url(repository)/tree/@helpers.encodeRefName(tag.name)">@tag.name</a></td>
<td>@gitbucket.core.helper.html.datetimeago(tag.time, false)</td>

View File

@@ -443,7 +443,7 @@ function string_score(string, word) {
* @param word {String} search word
* @param strings {Array[String]} search targets
* @param limit {Integer} result limit
* @return {Array[{score:"float matching score", string:"string target string", matchingPositions:"Array[Interger] matchng positions"}]}
* @return {Array[{score:"float matching score", string:"string target string", matchingPositions:"Array[Integer] matching positions"}]}
*/
function string_score_sort(word, strings, limit){
var ret = [], i=0, l = (word==="")?Math.min(strings.length, limit):strings.length;
@@ -466,7 +466,7 @@ function string_score_sort(word, strings, limit){
}
/**
* highlight by result.
* @param score {string:"string target string", matchingPositions:"Array[Interger] matchng positions"}
* @param score {string:"string target string", matchingPositions:"Array[Integer] matching positions"}
* @param highlight tag ex: '<b>'
* @return array of highlighted html elements.
*/

View File

@@ -18,7 +18,7 @@ class MergeServiceSpec extends FunSpec {
def initRepository(owner:String, name:String): File = {
val dir = createTestRepository(getRepositoryDir(owner, name))
using(Git.open(dir)){ git =>
createFile(git, s"refs/heads/master", "test.txt", "hoge" )
createFile(git, "refs/heads/master", "test.txt", "hoge" )
git.branchCreate().setStartPoint(s"refs/heads/master").setName(s"refs/pull/${issueId}/head").call()
}
dir

View File

@@ -11,15 +11,15 @@ class PullRequestServiceSpec extends FunSpec with ServiceSpecBase
describe("PullRequestService.getPullRequestFromBranch") {
it("""should
|return pull request if exists pull request from `branch` to `defaultBranch` and not closed.
|return pull request if exists pull request from `branch` to othre branch and not closed.
|return pull request if exists pull request from `branch` to other branch and not closed.
|return None if all pull request is closed""".stripMargin.trim) { withTestDB { implicit se =>
generateNewUserWithDBRepository("user1", "repo1")
generateNewUserWithDBRepository("user1", "repo2")
generateNewUserWithDBRepository("user2", "repo1")
generateNewPullRequest("user1/repo1/master", "user1/repo1/head2") // not target branch
generateNewPullRequest("user1/repo1/head1", "user1/repo1/master") // not target branch ( swap from, to )
generateNewPullRequest("user1/repo1/master", "user2/repo1/head1") // othre user
generateNewPullRequest("user1/repo1/master", "user1/repo2/head1") // othre repository
generateNewPullRequest("user1/repo1/master", "user2/repo1/head1") // other user
generateNewPullRequest("user1/repo1/master", "user1/repo2/head1") // other repository
val r1 = swap(generateNewPullRequest("user1/repo1/master2", "user1/repo1/head1"))
val r2 = swap(generateNewPullRequest("user1/repo1/master", "user1/repo1/head1"))
val r3 = swap(generateNewPullRequest("user1/repo1/master4", "user1/repo1/head1"))

View File

@@ -32,7 +32,7 @@ class HelpersSpec extends FunSpec with MockitoSugar {
assert(after == """Example Project. <a href="http://example.com">http://example.com</a>""")
}
it("should convert a mulitple links within text") {
it("should convert a multiple links within text") {
val before = "Example Project. http://example.com. (See also https://github.com/)"
val after = detectAndRenderLinks(before, repository)
assert(after == """Example Project. <a href="http://example.com">http://example.com</a>. (See also <a href="https://github.com/">https://github.com/</a>)""")