forked from mirrors/gecko-dev
		
	This for a few reasons: * The summary becomes the landing page for code quality: https://firefox-source-docs.mozilla.org/tools/static-analysis/summary.html * I don't think we need a full code quality category * Closer to the source-code-doc * All the files at the same place Differential Revision: https://phabricator.services.mozilla.com/D61767 --HG-- rename : tools/lint/docs/coding-style/coding_style_java.rst => docs/code-quality/coding-style/coding_style_java.rst rename : tools/lint/docs/coding-style/coding_style_other.rst => docs/code-quality/coding-style/coding_style_other.rst rename : tools/lint/docs/coding-style/coding_style_python.rst => docs/code-quality/coding-style/coding_style_python.rst rename : tools/lint/docs/coding-style/format_cpp_code_with_clang-format.rst => docs/code-quality/coding-style/format_cpp_code_with_clang-format.rst rename : tools/clang-tidy/docs/summary.rst => docs/code-quality/index.rst rename : tools/lint/docs/create.rst => docs/code-quality/lint/create.rst rename : tools/lint/docs/index.rst => docs/code-quality/lint/index.rst rename : tools/lint/docs/index.rst => docs/code-quality/lint/lint.rst rename : tools/lint/docs/linters/codespell.rst => docs/code-quality/lint/linters/codespell.rst rename : tools/lint/docs/linters/cpp-virtual-final.rst => docs/code-quality/lint/linters/cpp-virtual-final.rst rename : tools/lint/docs/linters/eslint-plugin-mozilla.rst => docs/code-quality/lint/linters/eslint-plugin-mozilla.rst rename : tools/lint/docs/linters/eslint-plugin-spidermonkey-js.rst => docs/code-quality/lint/linters/eslint-plugin-spidermonkey-js.rst rename : tools/lint/docs/linters/eslint.rst => docs/code-quality/lint/linters/eslint.rst rename : tools/lint/docs/linters/file-perm.rst => docs/code-quality/lint/linters/file-perm.rst rename : tools/lint/docs/linters/file-whitespace.rst => docs/code-quality/lint/linters/file-whitespace.rst rename : tools/lint/docs/linters/flake8.rst => docs/code-quality/lint/linters/flake8.rst rename : tools/lint/docs/linters/l10n.rst => docs/code-quality/lint/linters/l10n.rst rename : tools/lint/docs/linters/license.rst => docs/code-quality/lint/linters/license.rst rename : tools/lint/docs/linters/lintpref.rst => docs/code-quality/lint/linters/lintpref.rst rename : tools/lint/docs/linters/mingw-capitalization.rst => docs/code-quality/lint/linters/mingw-capitalization.rst rename : tools/lint/docs/linters/perfdocs.rst => docs/code-quality/lint/linters/perfdocs.rst rename : tools/lint/docs/linters/rstlinter.rst => docs/code-quality/lint/linters/rstlinter.rst rename : tools/lint/docs/linters/rustfmt.rst => docs/code-quality/lint/linters/rustfmt.rst rename : tools/lint/docs/usage.rst => docs/code-quality/lint/usage.rst rename : tools/clang-tidy/docs/index.rst => docs/code-quality/static-analysis.rst extra : moz-landing-system : lando
		
			
				
	
	
		
			68 lines
		
	
	
	
		
			2.4 KiB
		
	
	
	
		
			ReStructuredText
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
	
		
			2.4 KiB
		
	
	
	
		
			ReStructuredText
		
	
	
	
	
	
=================
 | 
						|
Java Coding style
 | 
						|
=================
 | 
						|
 | 
						|
-  We use the `Java Coding
 | 
						|
   Style <https://www.oracle.com/technetwork/java/codeconvtoc-136057.html>`__.
 | 
						|
   Quick summary:
 | 
						|
 | 
						|
   -  FirstLetterUpperCase for class names.
 | 
						|
   -  camelCase for method and variable names.
 | 
						|
   -  One declaration per line:
 | 
						|
 | 
						|
      .. code-block:: java
 | 
						|
 | 
						|
         int x, y; // this is BAD!
 | 
						|
         int a;    // split it over
 | 
						|
         int b;    // two lines
 | 
						|
 | 
						|
-  Braces should be placed like so (generally, opening braces on same
 | 
						|
   line, closing braces on a new line):
 | 
						|
 | 
						|
   .. code-block:: java
 | 
						|
 | 
						|
      public void func(int arg) {
 | 
						|
          if (arg != 0) {
 | 
						|
              while (arg > 0) {
 | 
						|
                  arg--;
 | 
						|
              }
 | 
						|
          } else {
 | 
						|
              arg++;
 | 
						|
          }
 | 
						|
      }
 | 
						|
 | 
						|
-  Places we differ from the Java coding style:
 | 
						|
 | 
						|
   -  Start class variable names with 'm' prefix (e.g.
 | 
						|
      mSomeClassVariable) and static variables with 's' prefix (e.g.
 | 
						|
      sSomeStaticVariable)
 | 
						|
   -  ``import`` statements:
 | 
						|
 | 
						|
      -  Do not use wildcard imports like \`import java.util.*;\`
 | 
						|
      -  Organize imports by blocks separated by empty line:
 | 
						|
         org.mozilla.*, android.*, com.*, net.*, org.*, then java.\*
 | 
						|
         This is basically what Android Studio does by default, except
 | 
						|
         that we place org.mozilla.\* at the front - please adjust
 | 
						|
         Settings -> Editor -> Code Style -> Java -> Imports
 | 
						|
         accordingly.
 | 
						|
      -  Within each import block, alphabetize import names with
 | 
						|
         uppercase before lowercase. For example, ``com.example.Foo`` is
 | 
						|
         before ``com.example.bar``
 | 
						|
 | 
						|
   -  4-space indents.
 | 
						|
   -  Spaces, not tabs.
 | 
						|
   -  Don't restrict yourself to 80-character lines. Google's Android
 | 
						|
      style guide suggests 100-character lines, which is also the
 | 
						|
      default setting in Android Studio. Java code tends to be long
 | 
						|
      horizontally, so use appropriate judgement when wrapping. Avoid
 | 
						|
      deep indents on wrapping. Note that aligning the wrapped part of a
 | 
						|
      line, with some previous part of the line (rather than just using
 | 
						|
      a fixed indent), may require shifting the code every time the line
 | 
						|
      changes, resulting in spurious whitespace changes.
 | 
						|
 | 
						|
-  For additional specifics on Firefox for Android, see the `Coding
 | 
						|
   Style guide for Firefox on
 | 
						|
   Android <https://wiki.mozilla.org/Mobile/Fennec/Android#Coding_Style>`__.
 | 
						|
-  The `Android Coding
 | 
						|
   Style <https://source.android.com/source/code-style.html>`__ has some
 | 
						|
   useful guidelines too.
 |