aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/skylark/javatests
diff options
context:
space:
mode:
authorGravatar fzaiser <fzaiser@google.com>2017-10-18 05:35:53 -0400
committerGravatar John Cater <jcater@google.com>2017-10-18 13:33:21 -0400
commitfd71d30f068deba3a4dcd78904498acf49c1d262 (patch)
tree2b43e76501d9172c9ed30264de4562864b4f2102 /src/tools/skylark/javatests
parent76b6d0a80e3f5cbcc420d147463aa4a2d715e54c (diff)
Skylint: change the end location of missing function docstring warnings.
The end location now ends before the first statement of the function. RELNOTES: none PiperOrigin-RevId: 172578911
Diffstat (limited to 'src/tools/skylark/javatests')
-rw-r--r--src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringCheckerTests.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringCheckerTests.java b/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringCheckerTests.java
index 377f0eed7c..876ce24688 100644
--- a/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringCheckerTests.java
+++ b/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringCheckerTests.java
@@ -38,12 +38,17 @@ public class DocstringCheckerTests {
@Test
public void reportMissingDocString() throws Exception {
String errorMessage =
- findIssues("# no module docstring", "def function():", " pass # no function docstring")
+ findIssues("# no module docstring", "def function():", " return # no function docstring")
.toString();
Truth.assertThat(errorMessage)
.contains("1:1-2:1: file has no module docstring [missing-docstring]");
Truth.assertThat(errorMessage)
- .contains("2:1-3:30: function 'function' has no docstring [missing-docstring]");
+ .contains("2:1-3:2: function 'function' has no docstring [missing-docstring]");
+ // The following function has zero statements since the parser throws `pass` statements away.
+ // Hence we have to check this case to make sure the end location is set correctly.
+ errorMessage = findIssues("def function():", " pass # no function docstring").toString();
+ Truth.assertThat(errorMessage)
+ .contains("1:1-2:30: function 'function' has no docstring [missing-docstring]");
}
@Test