Kuangcp/mythpoi

View on GitHub

Showing 12 of 12 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  private static HSSFCellStyle getContentCellStyle(HSSFWorkbook workbook) {
    // 设置字体
    HSSFFont font = workbook.createFont();
    font.setFontHeightInPoints(mainConfig.getContentFontSize());
    font.setFontName(mainConfig.getContentFontName());
Severity: Major
Found in src/main/java/com/kuangcp/mythpoi/excel/ExcelExport.java and 1 other location - About 1 hr to fix
src/main/java/com/kuangcp/mythpoi/excel/ExcelExport.java on lines 191..210

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 124.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  private static HSSFCellStyle getColumnTitleCellStyle(HSSFWorkbook workbook) {
    HSSFFont font = workbook.createFont();
    font.setFontHeightInPoints(mainConfig.getTitleFontSize());
    font.setBold(mainConfig.isTitleFontBold());
    font.setFontName(mainConfig.getTitleFontName());
Severity: Major
Found in src/main/java/com/kuangcp/mythpoi/excel/ExcelExport.java and 1 other location - About 1 hr to fix
src/main/java/com/kuangcp/mythpoi/excel/ExcelExport.java on lines 215..236

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 124.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method loadCellValue has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static void loadCellValue(CellType type, Field colField, Object target, HSSFCell cell)
      throws IllegalAccessException, ParseException {
    String fieldType = colField.getType().getSimpleName();

    switch (type) {
Severity: Minor
Found in src/main/java/com/kuangcp/mythpoi/excel/util/ExcelUtil.java - About 1 hr to fix

    Method loadCellValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      public static void loadCellValue(CellType type, Field colField, Object target, HSSFCell cell)
          throws IllegalAccessException, ParseException {
        String fieldType = colField.getType().getSimpleName();
    
        switch (type) {
    Severity: Minor
    Found in src/main/java/com/kuangcp/mythpoi/excel/util/ExcelUtil.java - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method getContentByMetas has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      private static List<Object[]> getContentByMetas(Class target, List<ExcelCellMeta> metaData,
          List<? extends ExcelTransform> originData) throws Exception {
        // 说明类里没有注解了的字段
        if (metaData.size() == 0) {
          return null;
    Severity: Minor
    Found in src/main/java/com/kuangcp/mythpoi/utils/base/ReadAnnotationUtil.java - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

    package com.kuangcp.mythpoi.excel.type;
    
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.ss.usermodel.CellType;
    Severity: Major
    Found in src/main/java/com/kuangcp/mythpoi/excel/type/LongHandler.java and 4 other locations - About 35 mins to fix
    src/main/java/com/kuangcp/mythpoi/excel/type/BooleanHandler.java on lines 1..21
    src/main/java/com/kuangcp/mythpoi/excel/type/DoubleHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/FloatHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/IntegerHandler.java on lines 1..20

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 43.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

    package com.kuangcp.mythpoi.excel.type;
    
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.ss.usermodel.CellType;
    src/main/java/com/kuangcp/mythpoi/excel/type/BooleanHandler.java on lines 1..21
    src/main/java/com/kuangcp/mythpoi/excel/type/FloatHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/IntegerHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/LongHandler.java on lines 1..20

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 43.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

    package com.kuangcp.mythpoi.excel.type;
    
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.ss.usermodel.CellType;
    src/main/java/com/kuangcp/mythpoi/excel/type/DoubleHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/FloatHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/IntegerHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/LongHandler.java on lines 1..20

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 43.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

    package com.kuangcp.mythpoi.excel.type;
    
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.ss.usermodel.CellType;
    src/main/java/com/kuangcp/mythpoi/excel/type/BooleanHandler.java on lines 1..21
    src/main/java/com/kuangcp/mythpoi/excel/type/DoubleHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/FloatHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/LongHandler.java on lines 1..20

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 43.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

    package com.kuangcp.mythpoi.excel.type;
    
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.ss.usermodel.CellType;
    Severity: Major
    Found in src/main/java/com/kuangcp/mythpoi/excel/type/FloatHandler.java and 4 other locations - About 35 mins to fix
    src/main/java/com/kuangcp/mythpoi/excel/type/BooleanHandler.java on lines 1..21
    src/main/java/com/kuangcp/mythpoi/excel/type/DoubleHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/IntegerHandler.java on lines 1..20
    src/main/java/com/kuangcp/mythpoi/excel/type/LongHandler.java on lines 1..20

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 43.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method mapFieldAndTitle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private static String[] mapFieldAndTitle(int colNum, HSSFRow row,
          List<ExcelCellMeta> metaList) {
        String[] titleList = new String[colNum];
        for (int i = 0; i < colNum; i++) {
          String temp = row.getCell(i).getStringCellValue();
    Severity: Minor
    Found in src/main/java/com/kuangcp/mythpoi/excel/ExcelImport.java - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method getCellMetaData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public static List<ExcelCellMeta> getCellMetaData(Class target) {
        List<ExcelCellMeta> list = new ArrayList<>();
        final Field[] fields = target.getDeclaredFields();
        for (Field field : fields) {
          if (field.isAnnotationPresent(ExcelConfig.class)) {
    Severity: Minor
    Found in src/main/java/com/kuangcp/mythpoi/utils/base/ReadAnnotationUtil.java - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Severity
    Category
    Status
    Source
    Language