robotframework-robocop
robotframework-robocop copied to clipboard
Rule: check if dependencies are sorted
Check if dependencies in Settings section are sorted: Libraries first, then Resource files. Can also check if they are sorted alphabetically or whatever way we decide to implement it.
It could be also possible to test if the import is local or external and propose sorting based on that (similiar as python):
Library Collections # internal
Library common.py # in the same directory
Library MyTestLib # external library
It could be also possible to test if the import is local or external and propose sorting based on that (similiar as python):
Library Collections # internal Library common.py # in the same directory Library MyTestLib # external library
We already have this inside 'wrong-import-order' rule but without checking libraries from the same directory.
Also, I am thinking if this is a good idea to implement this rule. I remember a discussion on slack (probably on #lsp or #devel channel) about the order of the imports and how they relate to each other. The conclusion was that sometimes different order is required due to specific variables relying on each other. So forcing user to keep one and only order is probably not a good idea... @bhirsz What do you think?
Yeah, resources and libraries are often depending in the order of import which would be contradicting with this rule. And like you wrote there is w ring-import-order already. We can close it
Another thing that comes to my mind is to create a rule for keeping settings of the same type grouped together, but again... I am not 100% sure if it will not trigger some problems with import order. @bhirsz What do you think? Can we implement such rule or we should give up with all sort of these rules related to order of imports?
If we don't have anything for it yet (I don't think so) it could be good idea. Robotidy already group settings, for example result here. Setting order other than imports (variables, resources, libraries) doesn't matter in execution. It looks better if let's say we're keeping tag settings together with other tag settings so I'm vouting for such rule.