Style Consistency

概要

コード内の全スタイル特徴の一貫性が一定値以上の際に取得できる実績です. 波括弧の位置や空白の有無など,同一ファイル内でのスタイルを一貫させることによって, コードの可読性を大幅に上げることが出来ます.

タイトル (Lv.1) タイトル (Lv.2) タイトル(Lv.3)
From start to finish Carrying out original intention Stylishest
課題 基準値 (Lv.1) 基準値 (Lv.2) 基準値 (Lv.3)
Trial 75%以上 90%以上 100%
Lexer 75%以上 90%以上 100%
Parser 75%以上 90%以上 100%
Checker 75%以上 90%以上 100%
Compiler 75%以上 90%以上 100%

スタイルの一貫性は,以下のようにして算出されます:

まず,スタイルを表す様々な特徴(「 while ブロック開始の波括弧前の空白」,「代入文の = の後の空白」など)において, 空白が挿入されているか/されていないかを二値的に計測します.

その後,各特徴において計測した結果に対し, (挿入・非挿入のうち多い方の回数)/全回数 を計算します. これがスタイルの一貫性を表す値です.

この計算方法によってスタイルの一貫性が計算されるため,その値は0.5〜1.0の値を取ります. Aveでは,これに100を掛けて百分率としたものを使用しています.

例えば,以下のコードで「 while ブロック開始の波括弧前の空白」という特徴の一貫性は, 2/3 = 0.666... ≒ 66.7 % となります.

コード例

//          ↓挿入
while (hoge) {
  doSomething();
}

...

//         ↓非挿入
while (hoge){
  doSomething();
}

...

//          ↓挿入
while (hoge) {
  doSomething();
}

スタイル特徴一覧

  • insert_space_after_and_in_type_parameter
  • insert_space_after_assignment_operator
  • insert_space_after_at_in_annotation
  • insert_space_after_at_in_annotation_type_declaration
  • insert_space_after_binary_operator
  • insert_space_after_closing_angle_bracket_in_type_arguments
  • insert_space_after_closing_angle_bracket_in_type_parameters
  • insert_space_after_closing_brace_in_block
  • insert_space_after_closing_paren_in_cast
  • insert_space_after_colon_in_assert
  • insert_space_after_colon_in_case
  • insert_space_after_colon_in_conditional
  • insert_space_after_colon_in_for
  • insert_space_after_colon_in_labeled_statement
  • insert_space_after_comma_in_allocation_expression
  • insert_space_after_comma_in_annotation
  • insert_space_after_comma_in_array_initializer
  • insert_space_after_comma_in_constructor_declaration_parameters
  • insert_space_after_comma_in_constructor_declaration_throws
  • insert_space_after_comma_in_enum_constant_arguments
  • insert_space_after_comma_in_enum_declarations
  • insert_space_after_comma_in_explicitconstructorcall_arguments
  • insert_space_after_comma_in_for_increments
  • insert_space_after_comma_in_for_inits
  • insert_space_after_comma_in_method_declaration_parameters
  • insert_space_after_comma_in_method_declaration_throws
  • insert_space_after_comma_in_method_invocation_arguments
  • insert_space_after_comma_in_multiple_field_declarations
  • insert_space_after_comma_in_multiple_local_declarations
  • insert_space_after_comma_in_parameterized_type_reference
  • insert_space_after_comma_in_superinterfaces
  • insert_space_after_comma_in_type_arguments
  • insert_space_after_comma_in_type_parameters
  • insert_space_after_ellipsis
  • insert_space_after_lambda_arrow
  • insert_space_after_opening_angle_bracket_in_parameterized_type_reference
  • insert_space_after_opening_angle_bracket_in_type_arguments
  • insert_space_after_opening_angle_bracket_in_type_parameters
  • insert_space_after_opening_brace_in_array_initializer
  • insert_space_after_opening_bracket_in_array_allocation_expression
  • insert_space_after_opening_bracket_in_array_reference
  • insert_space_after_opening_paren_in_annotation
  • insert_space_after_opening_paren_in_cast
  • insert_space_after_opening_paren_in_catch
  • insert_space_after_opening_paren_in_constructor_declaration
  • insert_space_after_opening_paren_in_enum_constant
  • insert_space_after_opening_paren_in_for
  • insert_space_after_opening_paren_in_if
  • insert_space_after_opening_paren_in_method_declaration
  • insert_space_after_opening_paren_in_method_invocation
  • insert_space_after_opening_paren_in_parenthesized_expression
  • insert_space_after_opening_paren_in_switch
  • insert_space_after_opening_paren_in_synchronized
  • insert_space_after_opening_paren_in_try
  • insert_space_after_opening_paren_in_while
  • insert_space_after_postfix_operator
  • insert_space_after_prefix_operator
  • insert_space_after_question_in_conditional
  • insert_space_after_question_in_wildcard
  • insert_space_after_semicolon_in_for
  • insert_space_after_semicolon_in_try_resources
  • insert_space_after_unary_operator
  • insert_space_before_and_in_type_parameter
  • insert_space_before_assignment_operator
  • insert_space_before_at_in_annotation_type_declaration
  • insert_space_before_binary_operator
  • insert_space_before_closing_angle_bracket_in_parameterized_type_reference
  • insert_space_before_closing_angle_bracket_in_type_arguments
  • insert_space_before_closing_angle_bracket_in_type_parameters
  • insert_space_before_closing_brace_in_array_initializer
  • insert_space_before_closing_bracket_in_array_allocation_expression
  • insert_space_before_closing_bracket_in_array_reference
  • insert_space_before_closing_paren_in_annotation
  • insert_space_before_closing_paren_in_cast
  • insert_space_before_closing_paren_in_catch
  • insert_space_before_closing_paren_in_constructor_declaration
  • insert_space_before_closing_paren_in_enum_constant
  • insert_space_before_closing_paren_in_for
  • insert_space_before_closing_paren_in_if
  • insert_space_before_closing_paren_in_method_declaration
  • insert_space_before_closing_paren_in_method_invocation
  • insert_space_before_closing_paren_in_parenthesized_expression
  • insert_space_before_closing_paren_in_switch
  • insert_space_before_closing_paren_in_synchronized
  • insert_space_before_closing_paren_in_try
  • insert_space_before_closing_paren_in_while
  • insert_space_before_colon_in_assert
  • insert_space_before_colon_in_case
  • insert_space_before_colon_in_conditional
  • insert_space_before_colon_in_default
  • insert_space_before_colon_in_for
  • insert_space_before_colon_in_labeled_statement
  • insert_space_before_comma_in_allocation_expression
  • insert_space_before_comma_in_annotation
  • insert_space_before_comma_in_array_initializer
  • insert_space_before_comma_in_constructor_declaration_parameters
  • insert_space_before_comma_in_constructor_declaration_throws
  • insert_space_before_comma_in_enum_constant_arguments
  • insert_space_before_comma_in_enum_declarations
  • insert_space_before_comma_in_explicitconstructorcall_arguments
  • insert_space_before_comma_in_for_increments
  • insert_space_before_comma_in_for_inits
  • insert_space_before_comma_in_method_declaration_parameters
  • insert_space_before_comma_in_method_declaration_throws
  • insert_space_before_comma_in_method_invocation_arguments
  • insert_space_before_comma_in_multiple_field_declarations
  • insert_space_before_comma_in_multiple_local_declarations
  • insert_space_before_comma_in_parameterized_type_reference
  • insert_space_before_comma_in_superinterfaces
  • insert_space_before_comma_in_type_arguments
  • insert_space_before_comma_in_type_parameters
  • insert_space_before_ellipsis
  • insert_space_before_lambda_arrow
  • insert_space_before_opening_angle_bracket_in_parameterized_type_reference
  • insert_space_before_opening_angle_bracket_in_type_arguments
  • insert_space_before_opening_angle_bracket_in_type_parameters
  • insert_space_before_opening_brace_in_annotation_type_declaration
  • insert_space_before_opening_brace_in_anonymous_type_declaration
  • insert_space_before_opening_brace_in_array_initializer
  • insert_space_before_opening_brace_in_block
  • insert_space_before_opening_brace_in_constructor_declaration
  • insert_space_before_opening_brace_in_enum_constant
  • insert_space_before_opening_brace_in_enum_declaration
  • insert_space_before_opening_brace_in_method_declaration
  • insert_space_before_opening_brace_in_switch
  • insert_space_before_opening_brace_in_type_declaration
  • insert_space_before_opening_bracket_in_array_allocation_expression
  • insert_space_before_opening_bracket_in_array_reference
  • insert_space_before_opening_bracket_in_array_type_reference
  • insert_space_before_opening_paren_in_annotation
  • insert_space_before_opening_paren_in_annotation_type_member_declaration
  • insert_space_before_opening_paren_in_catch
  • insert_space_before_opening_paren_in_constructor_declaration
  • insert_space_before_opening_paren_in_enum_constant
  • insert_space_before_opening_paren_in_for
  • insert_space_before_opening_paren_in_if
  • insert_space_before_opening_paren_in_method_declaration
  • insert_space_before_opening_paren_in_method_invocation
  • insert_space_before_opening_paren_in_parenthesized_expression
  • insert_space_before_opening_paren_in_switch
  • insert_space_before_opening_paren_in_synchronized
  • insert_space_before_opening_paren_in_try
  • insert_space_before_opening_paren_in_while
  • insert_space_before_parenthesized_expression_in_return
  • insert_space_before_parenthesized_expression_in_throw
  • insert_space_before_postfix_operator
  • insert_space_before_prefix_operator
  • insert_space_before_question_in_conditional
  • insert_space_before_question_in_wildcard
  • insert_space_before_semicolon
  • insert_space_before_semicolon_in_for
  • insert_space_before_semicolon_in_try_resources
  • insert_space_before_unary_operator
  • insert_space_between_brackets_in_array_type_reference
  • insert_space_between_empty_braces_in_array_initializer
  • insert_space_between_empty_brackets_in_array_allocation_expression
  • insert_space_between_empty_parens_in_annotation_type_member_declaration
  • insert_space_between_empty_parens_in_constructor_declaration
  • insert_space_between_empty_parens_in_enum_constant
  • insert_space_between_empty_parens_in_method_declaration
  • insert_space_between_empty_parens_in_method_invocation]

この実績のチェックには,Format Feature Extractor を用いています.

注釈

この実績は,「ブロック開始の波括弧の前には空白を置くべき!」などといった,信条を表すものではありません. 同一のファイル内ではバラバラのスタイルではなく,一貫したスタイルでコードを書くべきということです.

ちなみに

Eclipseでは Ctrl + Shift + F で, IntelliJ Ideaでは Ctrl + Alt + L でコードの自動フォーマットを行ってくれます. 便利なのでぜひ使いましょう.