aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/skylark/javatests
Commit message (Collapse)AuthorAge
* [Skylint] Fix a crash on analyzing augmented assignment to IndexExpression.Gravatar Taras Tsugrii2018-07-11
| | | | | | | | | | | | | | | | | | Fixes #5534. Skylint was operating under assumption that all lvalues have a single bound identifier, which is not true for `IndexExpression`s like ``` d["foo"] += "bar" ``` As a result, Skylint would crash. This change makes it handle cases without bound identifiers gracefully. Ideally `IndexExpression` assigments should be analyzed too, but it's a more involved change. Closes #5535. PiperOrigin-RevId: 204109060
* Warn when code uses FileType(), which is deprecated.Gravatar laurentlb2018-04-11
| | | | | RELNOTES: None. PiperOrigin-RevId: 192472412
* Skylint check for returning old-style providers.Gravatar laurentlb2018-03-22
| | | | | RELNOTES: None. PiperOrigin-RevId: 190071755
* Skylint: check for PACKAGE_NAME, REPOSITORY_NAME, and ctx.outputs.executableGravatar laurentlb2018-03-07
| | | | | RELNOTES: None. PiperOrigin-RevId: 188225156
* Skylint: Warn for the '/' operator (instead of '//').Gravatar laurentlb2018-03-07
| | | | | RELNOTES: None. PiperOrigin-RevId: 188217409
* Remove --incompatible_load_argument_is_label flagGravatar laurentlb2018-03-01
| | | | | | RELNOTES: Removed flag `--incompatible_load_argument_is_label`. PiperOrigin-RevId: 187479614
* Creates a new issue pointing out "Arguments:" as not preferred instead of ↵Gravatar Googler2018-02-22
| | | | | | | reporting that there is a missing 'Args:' section. RELNOTES: None. PiperOrigin-RevId: 186717757
* Clarify parser error for load() statementsGravatar brandjon2018-02-22
| | | | | RELNOTES: None PiperOrigin-RevId: 186693205
* Add linter check for deprecated ctx methods.Gravatar laurentlb2018-02-20
| | | | | RELNOTES: None. PiperOrigin-RevId: 186297559
* [Skylint] Do not crash ControlFlowChecker on nested functions.Gravatar Taras Tsugrii2018-02-13
| | | | | | | | | | | ControlFlowChecker has a precondition check that assumes nested functions do not occur. While this assumption is reasonable for a valid Skylark syntax, linter can actually be invoked on malformed files and users would get a stack trace instead of a human-readable linter error. Alternative and possibly a better strategy would to not run CFChecker in case parse errors are detected. fixes #4511 Closes #4512. PiperOrigin-RevId: 185538897
* Create a skylint and buildozer checker for preventing glob(**/*.java)Gravatar Googler2018-02-12
| | | | | | | | | For now we will only block Java recursive globs. Any other languages or extensions can be banned relatively easily. RELNOTES: Add lint check for discouraging glob(["**/*.java"]) PiperOrigin-RevId: 185417760
* Detect deprecated operations on dict() variables in SkylintGravatar cparsons2018-02-06
| | | | | RELNOTES: None. PiperOrigin-RevId: 184667932
* Skylint: Add a warning for the `+` operator on depsets.Gravatar laurentlb2017-12-19
| | | | | | | | | | | | | In many cases, users do: d = depset() d += ... To catch this issue, we use a heuristic to find which variable is a depset (in theory, it could be reassigned - but it's unlikely and that would be error-prone anyway) RELNOTES: None. PiperOrigin-RevId: 179536463
* Skylint: Add a warning for the '|' operator.Gravatar laurentlb2017-11-30
| | | | | | | Also, minor fix for the += operator check. RELNOTES: None. PiperOrigin-RevId: 177444203
* Use more precise categories for missing docstring.Gravatar laurentlb2017-11-27
| | | | | | | Split missing-docstring into missing-module-docstring and missing-function-docstring. RELNOTES: None. PiperOrigin-RevId: 176993716
* Improve error message for 'missing-return-value' check.Gravatar laurentlb2017-11-25
| | | | | RELNOTES: None. PiperOrigin-RevId: 176899549
* Linter: improve docstring formatting error messagesGravatar fzaiser2017-11-06
| | | | | RELNOTES: none PiperOrigin-RevId: 174479316
* Linter: don't require docstrings for short functionsGravatar fzaiser2017-11-03
| | | | | RELNOTES: none PiperOrigin-RevId: 174330237
* Linter: Tolerate whitespace-only lines and complain about misaligned closing ↵Gravatar brandjon2017-11-02
| | | | | | | quotes RELNOTES: None PiperOrigin-RevId: 174319420
* Linter: allow leading underscore in provider namesGravatar fzaiser2017-11-02
| | | | | RELNOTES: none PiperOrigin-RevId: 174318660
* Skylint: improve message for missing return and unitialized variablesGravatar fzaiser2017-11-02
| | | | | RELNOTES: none PiperOrigin-RevId: 174310059
* Skylint: also allow "UNUSED_" prefix in capital lettersGravatar fzaiser2017-11-02
| | | | | RELNOTES: none PiperOrigin-RevId: 174305935
* Fix typo in issue messageGravatar brandjon2017-11-02
| | | | | RELNOTES: None PiperOrigin-RevId: 174305030
* Skylint: improve message for unused list comprehensions.Gravatar fzaiser2017-10-30
| | | | | RELNOTES: none PiperOrigin-RevId: 173846739
* Skylint: also check for deprecations in dependencies.Gravatar fzaiser2017-10-27
| | | | | RELNOTES: none PiperOrigin-RevId: 173658526
* Skylint: improve error message for unused importsGravatar fzaiser2017-10-27
| | | | | | | Mention the pattern for re-exporting symbols. RELNOTES: none PiperOrigin-RevId: 173658431
* Skylint: improve messages about docstring errorsGravatar fzaiser2017-10-27
| | | | | | | While I was at it, I renamed a "*Tests" class to "*Test" for consistency. RELNOTES: none PiperOrigin-RevId: 173657530
* Skylint: docstring format: warn about wrong order of sections only onceGravatar fzaiser2017-10-24
| | | | | RELNOTES: none PiperOrigin-RevId: 173257316
* Parser: fix incorrect end location for statement suites.Gravatar fzaiser2017-10-24
| | | | | | | This used to be annoying for Skylint. RELNOTES: none PiperOrigin-RevId: 173249428
* Skylint: don't report unused variables starting with "unused_"Gravatar fzaiser2017-10-24
| | | | | RELNOTES: none PiperOrigin-RevId: 173140830
* Preserve `pass` statements in the Skylark AST.Gravatar fzaiser2017-10-23
| | | | | RELNOTES: none PiperOrigin-RevId: 173125138
* Skylint: check provider names for the suffix "Info"Gravatar fzaiser2017-10-23
| | | | | RELNOTES: none PiperOrigin-RevId: 173113056
* Skylint: docstring format: warn about empty sections and descriptions.Gravatar fzaiser2017-10-20
| | | | | | | In the process, I refactored and extended the line handling and error reporting a little. RELNOTES: none PiperOrigin-RevId: 172760285
* Skylint: change the end location of missing function docstring warnings.Gravatar fzaiser2017-10-18
| | | | | | | The end location now ends before the first statement of the function. RELNOTES: none PiperOrigin-RevId: 172578911
* Skylint: don't warn for unused initialization with 'None'.Gravatar fzaiser2017-10-18
| | | | | | | | | | | | | | | | | | | | It's good practice to place a "declaration" of a variable in a location that dominates all its uses, especially so if you want to document the variable. Hence we want no warning saying this declaration is unused. Example: var = None # don't warn about the unused declaration here if condition: var = 0 else: var = 1 As noted in the code, this also has the undesired side-effect of suppressing the warning here: var = None # doesn't warn either but ideally should var = 0 Fixing the latter problem is not worth the increased code complexity, in my opinion. RELNOTES: none PiperOrigin-RevId: 172442402
* Skylint: allow docstrings for global variables.Gravatar fzaiser2017-10-16
| | | | | | | | | | | | | | | | Global variables can have docstrings that are placed under their initialization. Example: variable = 0 """Documentation for the variable. Deprecated: This variable is deprecated. """ Note that docstrings are not required, even for public variables. Hence there are no changes to the DocstringChecker. RELNOTES: none PiperOrigin-RevId: 172324350
* Skylint: docstring format: mandatory order of description and sections.Gravatar fzaiser2017-10-16
| | | | | | | | | | | | | | | | Each docstring should include 1. a summary line 2. a more extensive description (optional) 3. an 'Args' section (if there are parameters) 4. a 'Returns' section (if there is a return value) 5. a 'Deprecated' section (if it is deprecated) in this order. If the order is different, there will be a warning. The same order is recommended for Java (http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#orderoftags). RELNOTES: none PiperOrigin-RevId: 172313475
* Skylint: add categories for issues.Gravatar fzaiser2017-10-13
| | | | | | | Having a short canonical name for each kind of finding (the category) makes it easier to document all the lints and for users to find the documentation for each lint. RELNOTES: none PiperOrigin-RevId: 171972645
* Skylint: set module docstring location to just the first lineGravatar fzaiser2017-10-13
| | | | | | | Previously, the location of the warning was the whole file. Now it is 1:1-2:1. This doesn't make sense if the file is empty but I think it's good enough since that's an edge case. RELNOTES: none PiperOrigin-RevId: 171942703
* Skylint: check for usage of deprecated functionsGravatar fzaiser2017-10-12
| | | | | | | This only covers functions deprecated in the same file. It does not yet recognize load()ed functions that are deprecated in another file. RELNOTES: none PiperOrigin-RevId: 171841455
* Skylint: report location ranges instead of just the start locationGravatar fzaiser2017-10-10
| | | | | RELNOTES: none PiperOrigin-RevId: 171532870
* Skylint: check for bad operationsGravatar fzaiser2017-09-29
| | | | | | | | So far, only checks for usages of '+' on dictionary literals and comprehensions. RELNOTES: none PiperOrigin-RevId: 170336917
* Skylint: ignore naming conventions for importsGravatar fzaiser2017-09-27
| | | | | | | | Often the author of a file doesn't have control over the naming in its dependencies, so we shouldn't warn about these. RELNOTES: none PiperOrigin-RevId: 170062766
* Skylint: check that load statements are at the top of the fileGravatar fzaiser2017-09-27
| | | | | RELNOTES: none PiperOrigin-RevId: 170057295
* Skylint: be less strict about indentation in docstringsGravatar fzaiser2017-09-21
| | | | | | | | | | | | Instead of enforcing two spaces of indentation, we now only enforce a positive number of spaces in indented lines. Reason: Apparently, a lot of docstrings in Skylark files are badly indented, so we should only warn about the worst offenders until a formatting tool is available. RELNOTES: none PiperOrigin-RevId: 169429429
* Skylint: report missing documentation for a function's return valueGravatar fzaiser2017-09-14
| | | | | | | | | | | | | | | | | | | | | | | | | | In addition to checking the function parameter documentation, skylint now also checks whether the return value is documented in a 'Returns:' section in the docstring. The same restrictions as for parameters apply: - Private functions need no documentation - If a function has a single line docstring, it need not document the return value. In addition, I improved the docstring parsing: - Previously, the beginning and end of a section (e.g. 'Args:', 'Returns:') were determined by line breaks. Now, they're determined by indentation and missing line breaks are reported. This change should make the docstring parser more robust. - Additional indentation is not warned against anymore. There are many situations where it makes sense, like example code. Both of these changes were motivated by the results of the linter on Skylark files "in the wild". RELNOTES: none PiperOrigin-RevId: 168660248
* Skylint: improve the naming conventions checkerGravatar fzaiser2017-09-12
| | | | | | | | | | | | | | | | | | | | | | | | Changes in behavior: * Local variables are also allowed to be UPPER_SNAKE_CASE. Upper case means that they're constants but this is not checked yet. * Providers are required to be UpperCamelCase. A variable FooBar is considered a provider if it appears in an assignment of the form "FooBar = provider(...)" * Shadowing of builtins (e.g. "True = False", "def fail()") is not allowed * The single-letter variable names 'O', 'l', 'I' are disallowed since they're easy to confuse * Multi-underscore names ('__', '___', etc.) are disallowed * Single-underscore names may only be written to, as in a, _ = tuple They may not be read, as in "f(_)". In the process, I also moved some code from UsageChecker to AstVisitorWithNameResolution to prevent duplication in NamingConventionsChecker. RELNOTES: none PiperOrigin-RevId: 168250396
* Skylint: add main linter class and clean up BUILD filesGravatar fzaiser2017-09-08
| | | | | RELNOTES: none PiperOrigin-RevId: 167846717
* Skylint: add lint for uninitialized variablesGravatar fzaiser2017-09-06
| | | | | RELNOTES: none PiperOrigin-RevId: 167614625
* Skylint: check the documentation of parameters in function docstringsGravatar fzaiser2017-09-04
| | | | | RELNOTES: none PiperOrigin-RevId: 167502103