Skip to content

Commit 9748c2a

Browse files
committed
Fix sonar issues
1 parent 519cecc commit 9748c2a

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/main/java/org/fugerit/java/github/issue/export/GithubIssueExport.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,6 @@ public static Object buildModel( String data, Class c ) throws JsonProcessingExc
328328
return objectMapper.readValue( data , c );
329329
}
330330

331-
public static String getValue( Object val ) {
332-
String res = null;
333-
if ( val != null ) {
334-
res = String.valueOf( val );
335-
}
336-
return res;
337-
}
338-
339331
private static void handleExcel( GithubIssueInfo info, List<List<String>> lines ) {
340332
SafeFunction.apply( () -> {
341333
String xlsFile = info.getProperty( ARG_XLSFILE );

src/main/java/org/fugerit/java/github/issue/export/helper/PoiHelper.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public class PoiHelper {
2020

2121
private PoiHelper() {}
2222

23+
/*
24+
* https://support.microsoft.com/en-gb/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
25+
*/
26+
public static final int MAX_XLS_CELL_LENGTH = 32767;
27+
2328
/*
2429
* Use with caution, bad performance
2530
*/
@@ -41,18 +46,20 @@ public static CellStyle getHeaderStyle( Workbook workbook ) {
4146
return style;
4247
}
4348

49+
public static String prepareCell( String currentCell ) {
50+
if ( "null".equalsIgnoreCase( currentCell ) ) {
51+
currentCell = "";
52+
} else if ( currentCell.length() > MAX_XLS_CELL_LENGTH ) {
53+
currentCell = currentCell.substring( 0, 32000 )+"[...]";
54+
}
55+
return currentCell;
56+
}
57+
4458
public static void addRow( String[] values, int index, Sheet sheet, CellStyle style) {
4559
Row row = sheet.createRow( index );
4660
for ( int k=0; k<values.length; k++ ) {
4761
Cell cell = row.createCell( k );
48-
String currentCell = values[k];
49-
if ( currentCell.length() > 32767 ) {
50-
currentCell = currentCell.substring( 0, 32000 )+"[...]";
51-
}
52-
if ( "null".equalsIgnoreCase( currentCell ) ) {
53-
currentCell = "";
54-
}
55-
cell.setCellValue( currentCell );
62+
cell.setCellValue( prepareCell( values[k] ) );
5663
if ( style != null ) {
5764
cell.setCellStyle( style );
5865
}

0 commit comments

Comments
 (0)