diff options
author | 2017-10-19 19:07:08 +0200 | |
---|---|---|
committer | 2017-10-20 14:04:05 +0200 | |
commit | d7e0b82470bbad1e768a4c1731321411d8ee5675 (patch) | |
tree | 51639067070a698e88ec90ce48d16c24bd53f5c7 /src/tools/skylark/javatests/com/google/devtools | |
parent | db07436b0112e2aea5e543066d4cdb387536ce7f (diff) |
Skylint: docstring format: warn about empty sections and descriptions.
In the process, I refactored and extended the line handling and error reporting a little.
RELNOTES: none
PiperOrigin-RevId: 172760285
Diffstat (limited to 'src/tools/skylark/javatests/com/google/devtools')
-rw-r--r-- | src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java b/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java index 27d2257226..56c5e2b073 100644 --- a/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java +++ b/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java @@ -135,6 +135,31 @@ public class DocstringUtilsTest { } @Test + public void emptySection() throws Exception { + List<DocstringParseError> errors = new ArrayList<>(); + DocstringUtils.parseDocstring( + "summary\n" + "\n" + "Args:\n" + "More description.\n", 0, errors); + Truth.assertThat(errors.toString()).contains("3: section is empty"); + + errors = new ArrayList<>(); + DocstringUtils.parseDocstring( + "summary\n" + "\n" + "Returns:\n" + "More description\n", 0, errors); + Truth.assertThat(errors.toString()).contains("3: section is empty"); + + errors = new ArrayList<>(); + DocstringUtils.parseDocstring( + "summary\n" + "\n" + "Deprecated:\n" + "More description\n", 0, errors); + Truth.assertThat(errors.toString()).contains("3: section is empty"); + } + + @Test + public void emptyParamDescription() throws Exception { + List<DocstringParseError> errors = new ArrayList<>(); + DocstringUtils.parseDocstring("summary\n" + "\n" + "Args:\n" + "" + " foo: \n\n", 0, errors); + Truth.assertThat(errors.toString()).contains("4: empty parameter description for 'foo'"); + } + + @Test public void docstringReturn() throws Exception { List<DocstringParseError> errors = new ArrayList<>(); DocstringInfo info = |