Code Monkey home page Code Monkey logo

test-openrewrite's Introduction

OpenRewrite test project

This demonstrates some issues that are currently tripping up OpenRewrite (as of 2024-07-13), version 5.35.0 (and rewrite-static-analysis version 1.11.0).

NeedBraces removes the else keyword, forgets to flip if condition if the if {} block as empty.

  1. Build it
./mvnw clean package
  1. Run it
./mvnw clean package exec:java --projects source-problems -Dexec.mainClass="ch.vingolds.testopenrewrite.Main"
  1. Rewrite it
./mvnw --activate-profiles openrewrite org.openrewrite.maven:rewrite-maven-plugin:run
  1. Run it again: does it fail?
./mvnw clean package exec:java --projects source-problems -Dexec.mainClass="ch.vingolds.testopenrewrite.Main"

You will see output like this:

Hello and welcome!
This line should not be executed!
[WARNING] 
java.lang.RuntimeException: code should not reach here! if you see this, rewrite has messed up.
    at ch.vingolds.testopenrewrite.WithEmptyBlock.shouldNotFlipCondition (WithEmptyBlock.java:33)
  1. See the issue:
git diff source-problems/src/main/java/ch/vingolds/testopenrewrite/WithEmptyBlock.java

NormalizeLineBreaks does not actually do anything

The NormalizeLineBreaks and NormalizeTabsOrSpaces don't normalize \r\n\ Windows style line breaks to \n Unix style line breaks at all.

NeedBraces loses or misplaces comments

After rewrite, the comments in WithCommentPlacingInBraces are messed up in several ways. Please examine diff:

git diff source-problems/src/main/java/ch/vingolds/testopenrewrite/WithCommentPlacingInBraces.java

test-openrewrite's People

Contributors

valters avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.