Skip to content

Commit

Permalink
Merge pull request #120 from DevFactory/release/local-variables-shoul…
Browse files Browse the repository at this point in the history
…d-not-declare-and-return-immediately-fix-1

Code quality fix - Local Variables should not be declared and then immediately returned or thrown.
  • Loading branch information
anujgandharv committed May 25, 2016
2 parents 18072b1 + 3ea91ab commit 6e79bb2
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public abstract class AbstractConverter<Type> implements ParamAwareConverter<Typ
*
* @return the Class variable representing the Type object
*/
@SuppressWarnings("unchecked")
public Class<Type> convertTo() {
@SuppressWarnings("unchecked")
Class<Type> type = (Class<Type>) ((ParameterizedType) getClass().getGenericSuperclass())
return (Class<Type>) ((ParameterizedType) getClass().getGenericSuperclass())
.getActualTypeArguments()[0];
return type;
}

public Type convert(Map<String , Object> convertFrom , String paramName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ public Object[] getAllArguments(boolean nullsOk) throws CouldNotGenerateValueExc

private int getConstructorParameterCount() {
List<EasyParamSignature> signatures = EasyParamSignature.signatures(fClass.getOnlyConstructor());
int constructorParameterCount = signatures.size();
return constructorParameterCount;
return signatures.size();
}

public Object[] getArgumentStrings(boolean nullsOk) throws CouldNotGenerateValueException {
Expand Down Expand Up @@ -192,8 +191,7 @@ private Format formatToUse(EasyFrameworkMethod testMethod) {
}
Format classLevelFormat = fClass.getJavaClass().getAnnotation(Format.class);
Format methodLevelFormat = testMethod.getAnnotation(Format.class);
Format formatToUse = methodLevelFormat != null ? methodLevelFormat : classLevelFormat != null ? classLevelFormat : policyLevelFormat;
return formatToUse;
return methodLevelFormat != null ? methodLevelFormat : classLevelFormat != null ? classLevelFormat : policyLevelFormat;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public JRDataSource buildDefaultTestReport(Map<String, Object> reportParameters)
* @param reportParameters
*/
public JRDataSource buildTestMethodDurationReport(Map<String, Object> reportParameters) {
JRDataSource methodDurationDataSource = fillMethodDurationReportDataParametersAndGetDataSource(reportParameters, reportDataContainer.getClassName(), reportDataContainer.getMethodTestResults());
return methodDurationDataSource;
return fillMethodDurationReportDataParametersAndGetDataSource(reportParameters, reportDataContainer.getClassName(), reportDataContainer.getMethodTestResults());
}

private void fillMainReportDataParameters(Map<String, Object> reportParameters, String className, Map<String, List<TestResultBean>> methodTestResults) {
Expand Down Expand Up @@ -112,9 +111,8 @@ private JRDataSource fillMethodDurationReportDataParametersAndGetDataSource(Map<

reportParameters.put(CLASS_NAME, className);

JRDataSource methodDurationDataSource = new JRBeanCollectionDataSource(methodDurationReportBeans);
return new JRBeanCollectionDataSource(methodDurationReportBeans);

return methodDurationDataSource;
}

/**
Expand Down Expand Up @@ -236,8 +234,7 @@ private BufferedImage getPercentageImage(String itemName, ReportTotalsBean testR
DefaultPieDataset pieChartDataset = ChartUtils.getPieChartDataset(totalsDatasetValuesMap);

JFreeChart pieChart = ChartUtils.getPieChart("", pieChartDataset);
BufferedImage percentageImage = ChartUtils.getBufferedImageChartImage(pieChart, 150, 150);
return percentageImage;
return ChartUtils.getBufferedImageChartImage(pieChart, 150, 150);
}

/**
Expand All @@ -251,8 +248,7 @@ private BufferedImage getMethodDurationImage(String chartName, List<Duration> du
CategoryDataset lineDataset = ChartUtils.createDatasetCountLine(durationBeans, "count");

JFreeChart dualAxisChart = ChartUtils.getDualAxisChart(chartName, barDataset, lineDataset);
BufferedImage methodDurationImage = ChartUtils.getBufferedImageChartImage(dualAxisChart, 800, 600);
return ChartUtils.getBufferedImageChartImage(dualAxisChart, 800, 600);

return methodDurationImage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,12 @@ private JasperReport getCompiledReport(Report.REPORT_TYPE type, EXPORT_FORMAT ex

private JasperPrint getJasperPrint(JasperReport jasperReport, JRDataSource dataSource,
Map<String, Object> jasperParameters) throws JRException {
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameters, dataSource);
return jasperPrint;
return JasperFillManager.fillReport(jasperReport, jasperParameters, dataSource);
}

private JasperReport getJasperReport(String reportResource) throws JRException {
InputStream defaultReportInputStream = ClassLoader.class.getResourceAsStream(reportResource);
JasperReport jasperReport = JasperCompileManager.compileReport(defaultReportInputStream);
return jasperReport;
return JasperCompileManager.compileReport(defaultReportInputStream);
}

private void exportPDF(String destinationFolder, String reportName, JasperPrint jasperPrint) throws JRException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public class ChartUtils {
* @return BufferedImage
*/
public static BufferedImage getBufferedImageChartImage(JFreeChart chart, int width, int height) {
BufferedImage createBufferedImage = chart.createBufferedImage(width, height);
return createBufferedImage;
return chart.createBufferedImage(width, height);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/easetech/easytest/util/CommonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public static String createDefaultOutputFolder(String destinationFolder) {

public static String getCurrentFolder() {
File file = new File("");
String absolutePath = file.getAbsolutePath();
return absolutePath;
return file.getAbsolutePath();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/easetech/easytest/util/GeneralUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public static String createDefaultOutputFolder(String destinationFolder) {

public static String getCurrentFolder() {
File file = new File("");
String absolutePath = file.getAbsolutePath();
return absolutePath;
return file.getAbsolutePath();
}

/**
Expand Down

0 comments on commit 6e79bb2

Please sign in to comment.