Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arolfes/e59333a93c2322869c1f41bb1dcd81ac to your computer and use it in GitHub Desktop.
Save arolfes/e59333a93c2322869c1f41bb1dcd81ac to your computer and use it in GitHub Desktop.
my eclipse settings for save actions and compiler warnings

Save Actions and Compiler Warnings in eclipse

Save Actions

Save Actions

❗ All Code will be changed

Code Organizing

Save Actions 1

Code Style

Save Actions 2

Member Accesses

Save Actions 3

Missing code

Save Actions 4

Unnecessary Code

Save Actions 5

  • Type inferenz
  • available since JAVA 7
Map<String, Object> notSoCoolMap = new HashMap<String, Object>();
// will become
Map<String, Object> coolMap = new HashMap<>();

Compiler Warnings

Code Style

Compiler Warnings 1

indirect access to static members

// instead of
org.mockito.Mockito.any();
//better do
org.mockito.Matchers.any();
// because this method is declared in Matchers

try-with-resource

@Test
public void traditional() throws Exception {
  DataSource dataSource = mock(DataSource.class);
  Connection connection = null;
  try {
    connection = dataSource.getConnection();
  } finally {
    if (connection != null) {
      connection.close();
    }
  }
}

@Test
public void tryWithResource() throws Exception {
  DataSource dataSource = mock(DataSource.class);
  try (Connection connection = dataSource.getConnection()) {
    // do something
  }
}

Potential programming problems

Compiler Warnings 2

Name shadowing and conflicts

Compiler Warnings 3

Deprecated and restricted API

Compiler Warnings 4

Unnecessary code

Compiler Warnings 5

Generic types

Compiler Warnings 6

Annotations

Compiler Warnings 7

Null analysis

Compiler Warnings 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment