Skip to content

InlineVariable to handle more complex expressions too #803

Description

@Pankraz76

What version of OpenRewrite are you using?

I am using
id 'org.openrewrite.rewrite' version '7.22.0' apply false
org.openrewrite.recipe:rewrite-static-analysis:2.23.0

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a single module project.

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

apply plugin: 'org.openrewrite.rewrite'

dependencies {
    rewrite('org.openrewrite.recipe:rewrite-static-analysis:2.23.0')
}

rewrite {
    activeRecipe('org.apache.kafka.openrewrite.SanityCheck')
    configFile = project.getRootProject().file("${rootDir}/config/sanity.yml")
    setExportDatatables(true)
    setFailOnDryRunResults(true)
}

What is the smallest, simplest way to reproduce the problem?

    private int nextValue(String topic) {
        AtomicInteger counter = topicCounterMap.computeIfAbsent(topic, k -> new AtomicInteger(0));
        return counter.getAndIncrement();
    }

What did you expect to see?

    private int nextValue(String topic) {
        return topicCounterMap.computeIfAbsent(topic, k -> new AtomicInteger(0)).getAndIncrement();
    }

What did you see instead?

    private int nextValue(String topic) {
        AtomicInteger counter = topicCounterMap.computeIfAbsent(topic, k -> new AtomicInteger(0));
        return counter.getAndIncrement();
    }

PS: please dont be the new checkstyle caring more and actually only about their bug-template instead of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions