sentilo/sentilo

View on GitHub
sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java

Summary

Maintainability
F
4 days
Test Coverage

File ExcelGeneratorUtils.java has 671 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Sentilo
 *
 * Original version 1.4 Copyright (C) 2013 Institut Municipal d’Informàtica, Ajuntament de
 * Barcelona. Modified by Opentrends adding support for multitenant deployments and SaaS.

    ExcelGeneratorUtils has 38 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class ExcelGeneratorUtils {
    
      private enum ListType {
        provider, application, component, sensor, sensortype, componenttype, permission, grant, user, alert, alertrule, tenant, tenantpermission, activesubscription, federationconfig, sector;
      }

      Method buildLocationCell has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        private static String buildLocationCell(final Component component) {
          final StringBuilder sbL = new StringBuilder();
          if (component.getLocation() != null) {
            if (component.getLocation().getCoordinates() != null && component.getLocation().getCoordinates().length > 0) {
              for (final LngLat coord : component.getLocation().getCoordinates()) {

      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 getColumnsNames has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public static List<String> getColumnsNames(final String listTypeNAme) {
      
          final ListType listType = ListType.valueOf(listTypeNAme);
      
          switch (listType) {

        Method getSensorExcelColumnNames has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private static List<String> getSensorExcelColumnNames() {
            final List<String> listColumnNames = new ArrayList<String>();
        
            listColumnNames.add(Constants.ID_PROP);
            listColumnNames.add(Constants.SENSOR_ID_PROP);

          Method getVisualConfiguration has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            private static String getVisualConfiguration(final VisualConfiguration visualConfiguration) {
              final Map<String, String> keyValues = new HashMap<String, String>();
              if (visualConfiguration != null) {
                if (StringUtils.hasText(visualConfiguration.getTimeZone())) {
                  keyValues.put(Constants.VISUAL_CONFIGURATION_TIMEZONE_PROP, visualConfiguration.getTimeZone());

          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 2 locations. Consider refactoring.
          Open

            private static List<String> getUserExcelColumnNames() {
              final List<String> listColumnNames = new ArrayList<String>();
              listColumnNames.add(Constants.USER_NAME_PROP);
              listColumnNames.add(Constants.NAME_PROP);
              listColumnNames.add(Constants.EMAIL_PROP);
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 440..462

          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 153.

          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 List<String> getProviderExcelColumnNames() {
              final List<String> listColumnNames = new ArrayList<String>();
              listColumnNames.add(Constants.ID_PROP);
              listColumnNames.add(Constants.NAME_PROP);
              listColumnNames.add(Constants.DESCRIPTION_PROP);
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 732..754

          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 153.

          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 List<String> getFederationConfigExcelColumnNames() {
              final List<String> listColumnNames = new LinkedList<String>();
              listColumnNames.add(Constants.ID_PROP);
              listColumnNames.add(Constants.NAME_PROP);
              listColumnNames.add(Constants.DESCRIPTION_PROP);
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 597..614

          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 145.

          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 List<String> getTenantExcelColumnNames() {
              final List<String> listColumnNames = new LinkedList<String>();
              listColumnNames.add(Constants.ID_PROP);
              listColumnNames.add(Constants.NAME_PROP);
              listColumnNames.add(Constants.DESCRIPTION_PROP);
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 713..730

          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 145.

          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 List<String> getTenantPermissionsExcelColumnNames() {
              final List<String> listColumnNames = new ArrayList<String>();
              listColumnNames.add(Constants.SOURCE_PROP);
              listColumnNames.add(Constants.TARGET_PROP);
              listColumnNames.add(Constants.TYPE_PROP);
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 402..414

          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 105.

          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 List<String> getComponentTypeExcelColumnNames() {
              final List<String> listColumnNames = new ArrayList<String>();
              listColumnNames.add(Constants.ID_PROP);
              listColumnNames.add(Constants.NAME_PROP);
              listColumnNames.add(Constants.DESCRIPTION_PROP);
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 640..652

          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 105.

          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 3 locations. Consider refactoring.
          Open

            private static List<String> getSensorTypesExcelColumnNames() {
              final List<String> listColumnNames = new ArrayList<String>();
              listColumnNames.add(Constants.ID_PROP);
              listColumnNames.add(Constants.NAME_PROP);
              listColumnNames.add(Constants.DESCRIPTION_PROP);
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 288..298
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 836..846

          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 85.

          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 3 locations. Consider refactoring.
          Open

            private static List<String> getPermissionsExcelColumnNames() {
              final List<String> listColumnNames = new ArrayList<String>();
              listColumnNames.add(Constants.SOURCE_PROP);
              listColumnNames.add(Constants.TARGET_PROP);
              listColumnNames.add(Constants.TYPE_PROP);
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 550..561
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 836..846

          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 85.

          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 3 locations. Consider refactoring.
          Open

            private static List<String> getSectorConfigExcelColumnNames() {
              final List<String> listColumnNames = new LinkedList<String>();
              listColumnNames.add(Constants.ID_PROP);
              listColumnNames.add(Constants.NAME_PROP);
              listColumnNames.add(Constants.DESCRIPTION_PROP);
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 288..298
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/ExcelGeneratorUtils.java on lines 550..561

          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 85.

          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

                  for (final LngLat coord : component.getLocation().getCoordinates()) {
                    if (sbL.length() > 0) {
                      sbL.append("\n");
                    }
                    sbL.append(coord.getLatitude() + ", " + coord.getLongitude());
          sentilo-catalog-web/src/main/java/org/sentilo/web/catalog/utils/CatalogUtils.java on lines 111..116

          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 42.

          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

          There are no issues that match your filters.

          Category
          Status