Skip to content

Checkstyle operator-wrap formatting: move binary operators to start of continuation line#1037

Merged
akshayrai merged 1 commit into
linkedin:masterfrom
akshayrai:akrai/checkstyle-operator-wrap
Jun 29, 2026
Merged

Checkstyle operator-wrap formatting: move binary operators to start of continuation line#1037
akshayrai merged 1 commit into
linkedin:masterfrom
akshayrai:akrai/checkstyle-operator-wrap

Conversation

@akshayrai

@akshayrai akshayrai commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

No behavior changes in any file. This PR contains formatting-only fixes for OperatorWrap violations reported by LinkedIn's internal Checkstyle configuration (a stricter superset of the OSS configuration). The rule is not currently enabled in OSS Brooklin's checkstyle.xml, so this PR resolves the latent violations without proposing a configuration change.

The updates only adjust whitespace, line breaks, and operator placement. Specifically, binary operators are moved to the beginning of continuation lines, as required by the rule, improving readability while producing identical bytecode.

Testing Done

No change in logic, PR checks only

…f continuation line

Mechanical formatting fix for OperatorWrap violations the LinkedIn-internal
checkstyle (a stricter superset of the OSS Checker) flags on the current
OSS Brooklin tree. No behavior change in any file -- only whitespace,
operator placement, and line-break position move. The rule is not
currently enabled in OSS Brooklin's own checkstyle.xml, so this PR
addresses the latent violations without proposing a config change.

The rule states that when a binary expression is split across two
lines, the operator must lead the continuation line rather than trail
the first line. The well-known argument is that the leading operator
makes the structure of the expression visible at the line break and
shifts the eye to the right place when scanning. Both styles produce
identical bytecode.

Before:
    foo &&
        bar
    "first part of message " +
        "second part"

After:
    foo
        && bar
    "first part of message "
        + "second part"

30 fixes across 15 files, by operator:

  '&&' (10):
    Coordinator.{getCustomCheckpointing, waitForStopToPropagateAndMarkDatastreamsStopped}
    DatastreamProducerRecord.equals (combined two lines into one
      contiguous run of && operators)
    DatastreamResources.{validateUpdateDatastreams, resume,
      resume (paused-or-stopped branch -> || variant)}
    KafkaMirrorMakerConnectorTask (topic-manager factory init)
    ReflectionUtils.findMatchingMethod (assignability check)

  '||' (2):
    ReflectionUtils.isCompatiblePrimitive (boxed-type pair check)
    DatastreamResources.resume

  '?' / ':' (10):
    BroadcastStrategy.getOrCreateDatastreamTask (multi-line ternary)
    Coordinator.onAssignmentChange (x2) -- isDatastreamUpdate
      handle-event picker
    DirectoryTransportProvider.copyPathToDir (file vs directory copy fn)
    KafkaBasedConnectorTaskMetrics ctor x3 (histogram registration
      gated by enableAdditionalMetrics)
    LoadBasedPartitionAssignmentStrategy (info-log throughput-assignment
      enabled/disabled formatter)
    StickyMulticastStrategy.assign (reuse-task vs create-new)
    StickyPartitionAssignmentStrategy.{constructExpectedNumberOfTasks,
      computePartitionsPerTask} (elastic-task vs default;
      allowedPartitionsPerTask threshold)

  '+' (7):
    Coordinator.{waitForStopToPropagateAndMarkDatastreamsStopped,
      assignPartitionsToInstances} (multi-line log/exception messages)
    DatastreamTaskImpl ctor (multi-line transient-exception message)
    EmbeddedZookeeper.start (multi-line LOG.info "Zookeeper started")
    LoadBasedPartitionAssigner.validatePartitionCountAndThrow
      (multi-line String.format message)

  '/' (1):
    LoadBasedTaskCountEstimator.getTaskCount (throughput / capacity
      division split across lines)

Motivation outside OSS Brooklin: brooklin-server consumes Brooklin
in-tree (subtree-merge at brooklin-core/) and runs a stricter
checkstyle on the merged code; the rule fires 30 times today, forcing
a build-level carve-out. With this PR merged upstream, brooklin-server's
next OSS sync inherits the cleanup and the rule drops out of its
checkstyle-suppress list.
@akshayrai akshayrai marked this pull request as ready for review June 29, 2026 10:17

@dhananjay-sawner dhananjay-sawner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akshayrai akshayrai merged commit 050d79b into linkedin:master Jun 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants