Prompt
Apply consistent formatting and organization conventions throughout the codebase to enhance readability and maintainability:
-
Follow the project’s
.editorconfigsettings for indentation style (tabs vs spaces) and other formatting rules. - Sort dependencies alphabetically in build scripts:
dependencies { optional("io.micrometer:context-propagation") optional("io.micrometer:micrometer-observation") optional("io.projectreactor:reactor-test") optional("org.jetbrains.kotlinx:kotlinx-coroutines-core") optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") } - Store stateless implementations as final fields rather than creating getter methods:
// Preferred: private final RowMapper<Actor> actorRowMapper = (rs, rowNum) -> { Actor actor = new Actor(); actor.setFirstName(rs.getString("first_name")); actor.setLastName(rs.getString("last_name")); return actor; }; // Not preferred: private RowMapper<Actor> getActorMapper() { return (rs, rowNum) -> { // implementation }; } - Prefer inline lambda expressions for simple operations rather than creating separate variables:
// Preferred: jdbcTemplate.update(connection -> { PreparedStatement ps = connection.prepareStatement(INSERT_SQL, new String[] { "id" }); ps.setString(1, name); return ps; }, keyHolder); // Not preferred: PreparedStatementCreator statementCreator = connection -> { // implementation }; jdbcTemplate.update(statementCreator, keyHolder);