Open godofredoc opened 1 year ago
@zanderso @jmagman is this accurate? what about objc?
@stuartmorgan is there a build in packages that enforces the code styles?
- x-clang-tidy enforce code style for c/c++ and python.
is this accurate? what about objc?
Mac Host clang-tidy
and Mac iOS clang-tidy
enforces code styles for Objective-C/Objective-C++.
https://github.com/flutter/engine/blob/8b3966c1f47ecf5190a614b83a26e7bdf558e7b7/.clang-tidy#L10
I'm having a lot of trouble making sense of this issue, and as written I don't think it makes sense. It is conflating syntactic style checking (e.g. where whitespace is/isn't allowed to go) with semantic "style" checking. Calling semantic checks "style" checks is not correct, in my opinion. Instead, we'd typically call those checks "linting" or "static analysis" depending on the specifics of how they're implemented and what sorts of things they're looking for.
So, instead of trying to make sense of this issue as stated, I'll just give my summary of what we're doing. Feel free to ask follow up questions if you need more details.
In the flutter/engine repo:
clang-format
, and similar tools, to enforce coding style around whitespace and other opinions about syntax. clang-format
does not look at python code. We use yapf
to format python code.clang-tidy
, and similar tools, to enforce issues with the semantics of the code. clang-tidy
also has some opinions about syntax, but that isn't the main thing we use it for. clang-tidy
also checks ObjectiveC code. clang-tidy
does not look at python code. We use pylint
to do semantic checking of python code.dartanalyzer
to do semantic checking of Dart code. dartanalyzer
might also have some opinions about syntax, but that isn't the main thing we use it for.dartformat
to check the syntax of Dart code because it does not follow Flutter's style guide.In the flutter/flutter repo:
dartanalyzer
to do semantic checking of Dart code. dartanalyzer
might also have some opinions about syntax, but that isn't the main thing we use it for.dartformat
to check the syntax of Dart code because it does not follow Flutter's style guide.Thanks for the information, I'll copy it to the wiki.
The bug description is a copy/paste from the best practices, mainly for tracking purposes of what is being updated for flutter. I'll share the feedback with the OSSF team working on best practices.
yeah we already do this in spades everywhere we can
@stuartmorgan is there a build in packages that enforces the code styles?
Dart, C++, C, Java, and Objective-C are all enforced by CI in flutter/packages. We don't yet have Swift (https://github.com/flutter/flutter/issues/41129) or Kotlin (https://github.com/flutter/flutter/issues/41129) (the latter we have close to zero non-flutter create
-generated code of right now though as the policy is not to use it for plugins yet).
The project MUST automatically enforce its selected coding style(s) if there is at least one FLOSS tool that can do so in the selected language(s).
This MAY be implemented using static analysis tool(s) and/or by forcing the code through code reformatters. In many cases the tool configuration is included in the project's repository (since different projects may choose different configurations). Projects MAY allow style exceptions (and typically will); where exceptions occur, they MUST be rare and documented in the code at their locations, so that these exceptions can be reviewed and so that tools can automatically handle them in the future. Examples of such tools include ESLint (JavaScript), Rubocop (Ruby), and devtools check (R). Coding standards enforced justification