Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-13802 Flink code style guide
  3. FLINK-13820

Breaking long function argument lists and chained method calls

    XMLWordPrintableJSON

    Details

      Description

      Breaking the line of too long statements (line longness is yet to be fully defined) to improve code readability in case of

      • Long function argument lists (declaration or call): void func(type1 arg1, type2 arg2, ...)
      • Long sequence of chained calls: list.stream().map(...).reduce(...).collect(...)...

      Rules:

      • Break the list of arguments/calls if the line exceeds limit or earlier if you believe that the breaking would improve the code readability
      • If you break the line then each argument/call should have a separate line, including the first one
      • Each new line argument/call should have one extra indentation relative to the line of the parent function name or called entity
      • The opening parenthesis always stays on the line of the parent function name
      • The possible thrown exception list is never broken and stays on the same last line
      • The dot of a chained call is always on the line of that chained call proceeding the call at the beginning

      Examples of breaking:

      • Function arguments
      public void func(
          int arg1,
          int arg2,
          ...) throws E1, E2, E3 {
          
      }
      • Chained method calls:
      values
          .stream()
          .map(...)
          .collect(...);

        Attachments

          Activity

            People

            • Assignee:
              azagrebin Andrey Zagrebin
              Reporter:
              azagrebin Andrey Zagrebin
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m