From 80b93a36061629c65972d2522a84695edff34bf8 Mon Sep 17 00:00:00 2001 From: Rebecca Song Date: Wed, 12 Aug 2020 20:04:51 -0400 Subject: [PATCH 1/6] Update rubocop_auto_correct_all tag --- doc/ale-ruby.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt index 142bb6b8..29a39c97 100644 --- a/doc/ale-ruby.txt +++ b/doc/ale-ruby.txt @@ -114,8 +114,8 @@ g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options* This variable can be changed to modify flags given to rubocop. -g:ale_ruby_rubocop_auto_correct_all *g:ale_ruby_rubocop_options* - *b:ale_ruby_rubocop_options* +g:ale_ruby_rubocop_auto_correct_all *g:ale_ruby_rubocop_auto_correct_all* + *b:ale_ruby_rubocop_auto_correct_all* Type: Number Default: `0` From 5f2aeba8cc7c5918bdcd054778a28837ada8def3 Mon Sep 17 00:00:00 2001 From: bratekarate Date: Sat, 26 Sep 2020 03:21:26 +0200 Subject: [PATCH 2/6] bibclean: update matchlist reges for bibclean > v2.11.4 --- ale_linters/bib/bibclean.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ale_linters/bib/bibclean.vim b/ale_linters/bib/bibclean.vim index 9056a9c3..1d1c9ec2 100644 --- a/ale_linters/bib/bibclean.vim +++ b/ale_linters/bib/bibclean.vim @@ -18,7 +18,12 @@ function! ale_linters#bib#bibclean#get_type(str) abort endfunction function! ale_linters#bib#bibclean#match_msg(line) abort - return matchlist(a:line, '^\(.*\) "stdin", line \(.*\): \(.*\)$') + " Legacy message pattern works for bibclean <= v2.11.4. If empty, try + " the new message pattern for bibtex > v2.11.4 + let l:matches_legacy = matchlist(a:line, '^\(.*\) stdin:\(\w\+\):\(.*\)$') + return ! empty(l:matches_legacy) + \ ? l:matches_legacy + \ : matchlist(a:line, '^\(.*\) "stdin", line \(.*\): \(.*\)$') endfunction function! ale_linters#bib#bibclean#match_entry(line) abort From 56242cb87469e9a448de5c60a086a41b3641a7c3 Mon Sep 17 00:00:00 2001 From: bratekarate Date: Sat, 26 Sep 2020 17:09:54 +0200 Subject: [PATCH 3/6] fix lint, fix variable semantics and update tests --- ale_linters/bib/bibclean.vim | 8 ++-- test/handler/test_bibclean_handler.vader | 57 +++++++++++++++++++++++- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/ale_linters/bib/bibclean.vim b/ale_linters/bib/bibclean.vim index 1d1c9ec2..f1610e00 100644 --- a/ale_linters/bib/bibclean.vim +++ b/ale_linters/bib/bibclean.vim @@ -20,10 +20,10 @@ endfunction function! ale_linters#bib#bibclean#match_msg(line) abort " Legacy message pattern works for bibclean <= v2.11.4. If empty, try " the new message pattern for bibtex > v2.11.4 - let l:matches_legacy = matchlist(a:line, '^\(.*\) stdin:\(\w\+\):\(.*\)$') - return ! empty(l:matches_legacy) - \ ? l:matches_legacy - \ : matchlist(a:line, '^\(.*\) "stdin", line \(.*\): \(.*\)$') + let l:matches_legacy = matchlist(a:line, '^\(.*\) "stdin", line \(\d\+\): \(.*\)$') + + return ! empty(l:matches_legacy) ? l:matches_legacy + \ : matchlist(a:line, '^\(.*\) stdin:\(\d\+\):\(.*\)$') endfunction function! ale_linters#bib#bibclean#match_entry(line) abort diff --git a/test/handler/test_bibclean_handler.vader b/test/handler/test_bibclean_handler.vader index 6179d7f5..9da52a92 100644 --- a/test/handler/test_bibclean_handler.vader +++ b/test/handler/test_bibclean_handler.vader @@ -4,7 +4,7 @@ Before: After: call ale#linter#Reset() -Execute(The bibclean handler should parse lines correctly): +Execute(The bibclean handler should parse lines from bibclean <= v2.11.4 correctly): AssertEqual \ [ @@ -19,6 +19,12 @@ Execute(The bibclean handler should parse lines correctly): \ 'type': 'E', \ 'text': 'Expected comma after last field ``keywords''''.', \ 'col': ' 1' + \ }, + \ { + \ 'lnum': '176', + \ 'type': 'W', + \ 'text': 'Unexpected DOI in URL value ``"https://doi.org/DOI"'''': move to separate DOI = "..." key/value in this entry.', + \ 'col': '14' \ } \ ], \ ale_linters#bib#bibclean#Handle(255, [ @@ -31,5 +37,52 @@ Execute(The bibclean handler should parse lines correctly): \ "?? File positions: input [main.bib] output [stdout]", \ "?? Entry input byte=2145 line=63 column= 1 output byte=2146 line=63 column= 0", \ "?? Value input byte=2528 line=71 column= 2 output byte=2527 line=70 column=49", - \ "?? Current input byte=2529 line=71 column= 3 output byte=2528 line=70 column=50" + \ "?? Current input byte=2529 line=71 column= 3 output byte=2528 line=70 column=50", + \ "%% \"stdin\", line 176: Unexpected DOI in URL value ``\"https://doi.org/DOI\"'': move to separate DOI = \"...\" key/value in this entry.", + \ "%% File positions: input [stdin] output [stdout]", + \ "%% Entry input byte=6813 line=174 column= 1 output byte=8543 line=227 column= 0", + \ "%% Value input byte=6890 line=176 column=14 output byte=8641 line=229 column=17", + \ "%% Current input byte=6938 line=176 column=62 output byte=8641 line=229 column=17" \ ]) + +Execute(The bibclean handler should parse lines of bibclean > v2.11.4 correctly): + + AssertEqual + \ [ + \ { + \ 'lnum': '60', + \ 'type': 'W', + \ 'text': 'Unexpected value in ``month = "09"''''.', + \ 'col': '17' + \ }, + \ { + \ 'lnum': '63', + \ 'type': 'E', + \ 'text': 'Expected comma after last field ``keywords''''.', + \ 'col': ' 1' + \ }, + \ { + \ 'lnum': '176', + \ 'type': 'W', + \ 'text': 'Unexpected DOI in URL value ``"https://doi.org/DOI"'''': move to separate DOI = "..." key/value in this entry.', + \ 'col': '14' + \ } + \ ], + \ ale_linters#bib#bibclean#Handle(255, [ + \ "%% stdin:60:Unexpected value in ``month = \"09\"''.", + \ "%% File positions: input [main.bib] output [stdout]", + \ "%% Entry input byte=1681 line=50 column= 1 output byte=1680 line=50 column= 0", + \ "%% Value input byte=2137 line=60 column=17 output byte=2137 line=60 column=17", + \ "%% Current input byte=2139 line=60 column=19 output byte=2137 line=60 column=17", + \ "?? stdin:71:Expected comma after last field ``keywords''.", + \ "?? File positions: input [main.bib] output [stdout]", + \ "?? Entry input byte=2145 line=63 column= 1 output byte=2146 line=63 column= 0", + \ "?? Value input byte=2528 line=71 column= 2 output byte=2527 line=70 column=49", + \ "?? Current input byte=2529 line=71 column= 3 output byte=2528 line=70 column=50", + \ "%% stdin:176:Unexpected DOI in URL value ``\"https://doi.org/DOI\"'': move to separate DOI = \"...\" key/value in this entry.", + \ "%% File positions: input [stdin] output [stdout]", + \ "%% Entry input byte=6813 line=174 column= 1 output byte=8543 line=227 column= 0", + \ "%% Value input byte=6890 line=176 column=14 output byte=8641 line=229 column=17", + \ "%% Current input byte=6938 line=176 column=62 output byte=8641 line=229 column=17" + \ ]) + From 7186b0437f0b2d1726d594c04e580f26746368fc Mon Sep 17 00:00:00 2001 From: fenuks Date: Mon, 9 Dec 2019 23:38:53 +0100 Subject: [PATCH 4/6] Add maven helper file; use maven wrapper if available instead of global 'mvn' executable --- ale_linters/java/javac.vim | 8 +----- autoload/ale/maven.vim | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 autoload/ale/maven.vim diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim index f866eb09..a5e57e6c 100644 --- a/ale_linters/java/javac.vim +++ b/ale_linters/java/javac.vim @@ -9,13 +9,7 @@ call ale#Set('java_javac_classpath', '') call ale#Set('java_javac_sourcepath', '') function! ale_linters#java#javac#RunWithImportPaths(buffer) abort - let l:command = '' - let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') - - if !empty(l:pom_path) && executable('mvn') - let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h')) - \ . 'mvn dependency:build-classpath' - endif + let l:command = ale#maven#BuildClasspathCommand(a:buffer) " Try to use Gradle if Maven isn't available. if empty(l:command) diff --git a/autoload/ale/maven.vim b/autoload/ale/maven.vim new file mode 100644 index 00000000..745f8c93 --- /dev/null +++ b/autoload/ale/maven.vim @@ -0,0 +1,51 @@ +" Description: Functions for working with Maven projects. +" +" Given a buffer number, find a Maven project root. +function! ale#maven#FindProjectRoot(buffer) abort + let l:wrapper_path = ale#path#FindNearestFile(a:buffer, 'mvnw') + + if !empty(l:wrapper_path) + return fnamemodify(l:wrapper_path, ':h') + endif + + let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') + + if !empty(l:pom_path) + return fnamemodify(l:pom_path, ':h') + endif + + return '' +endfunction + + +" Given a buffer number, find the path to the executable. +" First search on the path for 'mvnw' (mvnw.cmd on Windows), if nothing is found, +" try the global command. Returns an empty string if cannot find the executable. +function! ale#maven#FindExecutable(buffer) abort + let l:wrapper_cmd = has('unix') ? 'mvnw' : 'mvnw.cmd' + let l:wrapper_path = ale#path#FindNearestFile(a:buffer, l:wrapper_cmd) + + if executable(l:wrapper_path) + return l:wrapper_path + endif + + if executable('mvn') + return 'mvn' + endif + + return '' +endfunction + +" Given a buffer number, build a command to print the classpath of the root +" project. Returns an empty string if cannot build the command. +function! ale#maven#BuildClasspathCommand(buffer) abort + let l:executable = ale#maven#FindExecutable(a:buffer) + let l:project_root = ale#maven#FindProjectRoot(a:buffer) + + if !empty(l:executable) && !empty(l:project_root) + return ale#path#CdString(l:project_root) + \ . l:executable . ' dependency:build-classpath' + endif + + return '' +endfunction From 7857098cb03f7b50fe0343178b954e70cb8b4df3 Mon Sep 17 00:00:00 2001 From: isaif Date: Thu, 1 Oct 2020 16:23:49 +0530 Subject: [PATCH 5/6] Fix grammatical error in doc --- doc/ale.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ale.txt b/doc/ale.txt index 6ef137c1..b63c51a2 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -154,7 +154,7 @@ Any existing problems will be kept. 3.1 Linting On Other Machines *ale-lint-other-machines* ALE offers support for running linters or fixers on files you are editing -locally on other machines, so long as the other machine has access the file +locally on other machines, so long as the other machine has access to the file you are editing. This could be a linter or fixer run inside of a Docker image, running in a virtual machine, running on a remote server, etc. From 4466c479900cbdc029d3091beedda5f1729851ae Mon Sep 17 00:00:00 2001 From: fenuks Date: Mon, 16 Dec 2019 01:18:13 +0100 Subject: [PATCH 6/6] Add tests for maven.vim file --- .../maven-java-project/module1/mvnw | 0 .../maven-java-project/module1/mvnw.cmd | 0 .../maven-java-project/module1/pom.xml | 1 + .../module1/src/main/java/dummy1.java | 0 .../maven-java-project/module2/pom.xml | 1 + .../module2/src/main/java/dummy2.java | 0 test/maven-test-files/mvn | 0 .../src/main/java/dummy.java | 0 test/test_maven_build_classpath_command.vader | 48 +++++++++++++++++++ test/test_maven_find_executable.vader | 46 ++++++++++++++++++ test/test_maven_find_project_root.vader | 28 +++++++++++ 11 files changed, 124 insertions(+) create mode 100755 test/maven-test-files/maven-java-project/module1/mvnw create mode 100755 test/maven-test-files/maven-java-project/module1/mvnw.cmd create mode 100644 test/maven-test-files/maven-java-project/module1/pom.xml create mode 100644 test/maven-test-files/maven-java-project/module1/src/main/java/dummy1.java create mode 100644 test/maven-test-files/maven-java-project/module2/pom.xml create mode 100644 test/maven-test-files/maven-java-project/module2/src/main/java/dummy2.java create mode 100755 test/maven-test-files/mvn create mode 100644 test/maven-test-files/non-maven-project/src/main/java/dummy.java create mode 100644 test/test_maven_build_classpath_command.vader create mode 100644 test/test_maven_find_executable.vader create mode 100644 test/test_maven_find_project_root.vader diff --git a/test/maven-test-files/maven-java-project/module1/mvnw b/test/maven-test-files/maven-java-project/module1/mvnw new file mode 100755 index 00000000..e69de29b diff --git a/test/maven-test-files/maven-java-project/module1/mvnw.cmd b/test/maven-test-files/maven-java-project/module1/mvnw.cmd new file mode 100755 index 00000000..e69de29b diff --git a/test/maven-test-files/maven-java-project/module1/pom.xml b/test/maven-test-files/maven-java-project/module1/pom.xml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/maven-test-files/maven-java-project/module1/pom.xml @@ -0,0 +1 @@ + diff --git a/test/maven-test-files/maven-java-project/module1/src/main/java/dummy1.java b/test/maven-test-files/maven-java-project/module1/src/main/java/dummy1.java new file mode 100644 index 00000000..e69de29b diff --git a/test/maven-test-files/maven-java-project/module2/pom.xml b/test/maven-test-files/maven-java-project/module2/pom.xml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/maven-test-files/maven-java-project/module2/pom.xml @@ -0,0 +1 @@ + diff --git a/test/maven-test-files/maven-java-project/module2/src/main/java/dummy2.java b/test/maven-test-files/maven-java-project/module2/src/main/java/dummy2.java new file mode 100644 index 00000000..e69de29b diff --git a/test/maven-test-files/mvn b/test/maven-test-files/mvn new file mode 100755 index 00000000..e69de29b diff --git a/test/maven-test-files/non-maven-project/src/main/java/dummy.java b/test/maven-test-files/non-maven-project/src/main/java/dummy.java new file mode 100644 index 00000000..e69de29b diff --git a/test/test_maven_build_classpath_command.vader b/test/test_maven_build_classpath_command.vader new file mode 100644 index 00000000..2d8b38a5 --- /dev/null +++ b/test/test_maven_build_classpath_command.vader @@ -0,0 +1,48 @@ +Before: + Save $PATH + Save $PATHEXT + + let $PATHEXT = '.' + + call ale#test#SetDirectory('/testplugin/test') + runtime ale_linters/java/javac.vim + let g:expected_wrapper = '' + if has('unix') + let g:expected_wrapper = 'mvnw' + else + let g:expected_wrapper = 'mvnw.cmd' + endif + +After: + Restore + + unlet! g:expected_wrapper + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(Should use 'mvnw' in classpath command if available): + call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java') + + AssertEqual + \ ale#path#CdString(ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1')) + \ . ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1/' . g:expected_wrapper) + \ . ' dependency:build-classpath', + \ ale#maven#BuildClasspathCommand(bufnr('')) + +Execute(Should use 'mvn' in classpath command if it is executable and 'mvnw' is unavailable): + call ale#test#SetFilename('maven-test-files/maven-java-project/module2/src/main/java/dummy2.java') + let $PATH .= (has('win32') ? ';' : ':') + \ . ale#path#Simplify(g:dir . '/maven-test-files') + + AssertEqual + \ ale#path#CdString(ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module2')) + \ . 'mvn dependency:build-classpath', + \ ale#maven#BuildClasspathCommand(bufnr('')) + +Execute(Should return empty string if maven cannot be executed): + call ale#test#SetFilename('maven-test-files/non-maven-project/src/main/java/dummy.java') + + AssertEqual + \ '', + \ ale#maven#BuildClasspathCommand(bufnr('')) diff --git a/test/test_maven_find_executable.vader b/test/test_maven_find_executable.vader new file mode 100644 index 00000000..1d2f6da2 --- /dev/null +++ b/test/test_maven_find_executable.vader @@ -0,0 +1,46 @@ +Before: + Save $PATH + Save $PATHEXT + + " Count the maven executable without .exe as executable on Windows + let $PATHEXT = '.' + + call ale#test#SetDirectory('/testplugin/test') + runtime ale_linters/java/javac.vim + let g:expected_wrapper = '' + if has('unix') + let g:expected_wrapper = 'mvnw' + else + let g:expected_wrapper = 'mvnw.cmd' + endif + +After: + Restore + + unlet! g:expected_wrapper + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(Should return 'mvnw' if found in parent directory): + call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java') + + AssertEqual + \ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1/' . g:expected_wrapper), + \ ale#maven#FindExecutable(bufnr('')) + +Execute(Should return 'mvn' if 'mvnw' not found in parent directory): + call ale#test#SetFilename('maven-test-files/maven-java-project/module2/src/main/java/dummy2.java') + let $PATH .= (has('win32') ? ';' : ':') + \ . ale#path#Simplify(g:dir . '/maven-test-files') + + AssertEqual + \ 'mvn', + \ ale#maven#FindExecutable(bufnr('')) + +Execute(Should return empty string if 'mvnw' not in parent directory and mvn not in path): + call ale#test#SetFilename('mvn-test-files/java-maven-project/module2/src/main/java/dummy2.java') + + AssertEqual + \ '', + \ ale#gradle#FindExecutable(bufnr('')) diff --git a/test/test_maven_find_project_root.vader b/test/test_maven_find_project_root.vader new file mode 100644 index 00000000..3a2138d1 --- /dev/null +++ b/test/test_maven_find_project_root.vader @@ -0,0 +1,28 @@ +Before: + call ale#test#SetDirectory('/testplugin/test') + runtime ale_linters/kotlin/javac.vim + +After: + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(Should return directory for 'mvnw' if found in parent directory): + call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java') + + AssertEqual + \ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1'), + \ ale#maven#FindProjectRoot(bufnr('')) + +Execute(Should return directory for 'pom.xml' if found in parent directory): + call ale#test#SetFilename('maven-test-files/maven-java-project/module2/src/main/java/dummy2.java') + + AssertEqual + \ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module2'), + \ ale#maven#FindProjectRoot(bufnr('')) + +Execute(Should return empty string if maven files are not found in parent directory): + call ale#test#SetFilename('maven-test-files/non-maven-project/src/main/java/dummy.java') + + AssertEqual + \ '', + \ ale#maven#FindProjectRoot(bufnr(''))