Commit Graph

3 Commits

Author SHA1 Message Date
Fabian Kosmale 66368ffdd9 qmllint: Improve parent handling
- Do not warn about parent access in unknown components
  This avoids false positive warnings when an imported component could not
  be found (or when it actually was not imported).
  We still warn about the component which could not be found, so the user
  is still informed that something is not right.

  We also still emit a warning when we know the properties of a component,
  and parent is not one of them.
- Do not recommend the use of parent to address the root components
  properties. For this to work, we would need to know whether the root
  component reparents its children or not. Moreover, id lookups are
  actually faster than parent lookups.

Change-Id: I83d0e71e4bf20d34a3e6d836c2b123b2bf0d416e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-26 09:00:07 +02:00
Fabian Kosmale 53e7927fdf qmllint: Improve signal handler recommendations
- Fix the case where multiple unqualified accesses would be mapped to
  the same signal (wrong in all but one cases), as the event parameter
  has the same name and we were using a QHash. Fixed by using QMultiHash
  and searching for the matching signal handler (by location)
- Recommend arrow functions for single line event handlers

Change-Id: I3cbb85fe0e49b454908ca03b4c86318ef02e364c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-25 13:13:16 +02:00
Fabian Kosmale 392521048c Extend linter to check for unqualified ids
The linter has gained a new option (-U/--check-unqualified).
If run with this option, it warns about occurrences of unqualified identifiers.
Furthermore, it attempts to detect the reason for why the identifier can be
used unqalified:

- If the id originates from the root element, it suggests to qualify the
  access either with the root element's id, or with "parent" if applicable.

- If the id is the parameter of a signal, it suggests to use functions in the
  handler, instead of relying on the signal parameters to be "magically"
  injected into scope.

The linter does not attempt to handle with statements, but warns the
user instead that they are a bad idea.

Change-Id: I9aaf28c37595d84886a1071d49b86799b222a617
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-12 15:31:16 +02:00