CloudSlang/cs-actions

View on GitHub
cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala

Summary

Maintainability
F
3 days
Test Coverage

Function execute has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

  @Action(name = UPDATE_SQL_INSTANCE_OPERATION_NAME,
    description = UPDATE_SQL_INSTANCE_OPERATION_DESCRIPTION,
    outputs = Array(
      new Output(value = RETURN_CODE, description = RETURN_CODE_DESC),
      new Output(value = RETURN_RESULT, description = RETURN_RESULT_DESC),

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

Function execute has 162 lines of code (exceeds 25 allowed). Consider refactoring.
Open

              @Param(value = PRETTY_PRINT, description = PRETTY_PRINT_DESC) prettyPrintInp: String): util.Map[String, String] = {

    val asyncStr = defaultIfEmpty(asyncInp, TRUE)
    val timeoutStr = defaultIfEmpty(timeoutInp, DEFAULT_SYNC_TIMEOUT)
    val pollingIntervalStr = defaultIfEmpty(pollingIntervalInp, DEFAULT_POLLING_INTERVAL)

    Method execute has 22 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def execute(@Param(value = PROJECT_ID, required = true, encrypted = true, description = PROJECT_ID_DESC) projectId: String,
                  @Param(value = ACCESS_TOKEN, required = true, encrypted = true, description = ACCESS_TOKEN_DESC) accessToken: String,
                  @Param(value = INSTANCE_ID, required = true, description = INSTANCE_ID_DESC) instanceId: String,
                  @Param(value = ZONE, description = ZONE_DESC) zone: String,
                  @Param(value = MACHINE_TYPE, description = MACHINE_TYPE_DESC) machineType: String,

      Avoid too many return statements within this function.
      Open

                return getFailureResultsMap(validationStream.mkString(NEW_LINE))

        Avoid too many return statements within this function.
        Open

                  return getFailureResultsMap(validationStream.mkString(NEW_LINE))

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

                      if (ipAddresses.size() > 1) {
                        if (ipAddresses.get(1).getType.equals(IP_ADDRESS_TYPE_PRIMARY)) {
                          publicIPAddress = sqlInstance.getIpAddresses.get(1).getIpAddress
                        } else if (ipAddresses.get(1).getType.equals(IP_ADDRESS_TYPE_PRIVATE)) {
                          privateIPAddress = ipAddresses.get(1).getIpAddress
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/CreateSQLInstance.scala on lines 188..194
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/CreateSQLInstance.scala on lines 195..201
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/GetSQLInstance.scala on lines 118..124
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/GetSQLInstance.scala on lines 125..131
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 237..243

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

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

                      if (ipAddresses.size() > 0) {
                        if (ipAddresses.get(0).getType.equals(IP_ADDRESS_TYPE_PRIMARY)) {
                          publicIPAddress = sqlInstance.getIpAddresses.get(0).getIpAddress
                        } else if (ipAddresses.get(0).getType.equals(IP_ADDRESS_TYPE_PRIVATE)) {
                          privateIPAddress = ipAddresses.get(0).getIpAddress
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/CreateSQLInstance.scala on lines 188..194
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/CreateSQLInstance.scala on lines 195..201
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/GetSQLInstance.scala on lines 118..124
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/GetSQLInstance.scala on lines 125..131
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 244..250

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

          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

                if (preferredMaintenanceWindowHour.isEmpty) {
                  preferredMaintenanceWindowHourVal = sqlInstanceSettings.getMaintenanceWindow.getHour.toString
                } else {
                  if (validateNonNegativeInteger(preferredMaintenanceWindowHour, PREFERRED_MAINTENANCE_WINDOW_DAY).nonEmpty) {
                    return getFailureResultsMap(validationStream.mkString(NEW_LINE))
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 180..188
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 200..208

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

          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

                if (isIPV4Enabled.isEmpty) {
                  isIPV4EnabledVal = sqlInstanceSettings.getIpConfiguration.getIpv4Enabled.toString
                } else {
                  if (validateBoolean(isIPV4Enabled, IS_IPV4_ENABLED).nonEmpty) {
                    return getFailureResultsMap(validationStream.mkString(NEW_LINE))
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 180..188
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 190..198

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

          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

                if (preferredMaintenanceWindowDay.isEmpty) {
                  preferredMaintenanceWindowDayVal = sqlInstanceSettings.getMaintenanceWindow.getDay.toString
                } else {
                  if (validateNonNegativeInteger(preferredMaintenanceWindowDay, PREFERRED_MAINTENANCE_WINDOW_DAY).nonEmpty) {
                    return getFailureResultsMap(validationStream.mkString(NEW_LINE))
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 190..198
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 200..208

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

          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

                if (storageCapacity.isEmpty) {
                  storageCapacityVal = sqlInstanceSettings.getDataDiskSizeGb.toString
                } else {
                  if (validateDiskSize(storageCapacity, STORAGE_CAPACITY).nonEmpty) {
                    return getFailureResultsMap(validationStream.mkString(NEW_LINE))
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 170..178

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

          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

                if (storageAutoResize.isEmpty) {
                  storageAutoResizeVal = sqlInstanceSettings.getStorageAutoResize.toString
                } else {
                  if (validateBoolean(storageAutoResize, STORAGE_AUTO_RESIZE).nonEmpty) {
                    return getFailureResultsMap(validationStream.mkString(NEW_LINE))
          cs-google/src/main/scala/io/cloudslang/content/google/actions/databases/sql/instances/UpdateSQLInstance.scala on lines 160..168

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

          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