SonarOpenCommunity / sonar-cxx

Method can be declared static JAVA-W1057
Anti-pattern
Major
6 months agoa year old
53    assertThat(hasPrivateConstructor(GrammarFunctions.Standard.class)).isTrue();
54  }
55
56  private static final boolean hasPrivateConstructor(Class cls) throws Exception {57    var constructor = cls.getDeclaredConstructor();58    var result = !constructor.isAccessible();59    constructor.setAccessible(true);60    constructor.newInstance();61    return result;62  }63
64}
164    return checkMessage;
165  }
166
167  private static final CheckMessage mockCheckMessage(Integer line, String message) {168    return mockCheckMessage(line, message, null);169  }170
171}
155      .noMore();
156  }
157
158  private static final CheckMessage mockCheckMessage(Integer line, String message, Double cost) {159    CheckMessage checkMessage = mock(CheckMessage.class);160    when(checkMessage.getLine()).thenReturn(line);161    when(checkMessage.getDefaultMessage()).thenReturn(message);162    when(checkMessage.getText(Mockito.any(Locale.class))).thenReturn(message);163    when(checkMessage.getCost()).thenReturn(cost);164    return checkMessage;165  }166
167  private static final CheckMessage mockCheckMessage(Integer line, String message) {
168    return mockCheckMessage(line, message, null);