botorabi/HomieCenter

View on GitHub

Showing 19 of 19 total issues

File FRITZBox.java has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2018 - 2021 by Botorabi. All rights reserved.
 * https://github.com/botorabi/HomieCenter
 *
 * License: MIT License (MIT), read the LICENSE text in
Severity: Minor
Found in src/main/java/net/vrfun/homiecenter/fritzbox/FRITZBox.java - About 2 hrs to fix

    Method handleDeviceCommand has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public void handleDeviceCommand(long deviceId, @NonNull final String command) throws Exception {
            final String CMD_TEMPERATURE = "temperature=";
            final String CMD_ON = "on";
            final String CMD_OFF = "off";
    
    
    Severity: Minor
    Found in src/main/java/net/vrfun/homiecenter/fritzbox/FRITZBox.java - About 1 hr to fix

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

              return "switch device id: " + getId() + ", " +
                      "ain: " + getAIN() + ", " +
                      "firmware: " + getFirmware() + ", " +
                      "product name: " + getProductName() + ", " +
                      "name: " + getName() + ", " +
      src/main/java/net/vrfun/homiecenter/model/HeatControllerDeviceInfo.java on lines 100..105

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

      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

              return "heat controller id: " + getId() + ", " +
                      "ain: " + getAIN() + ", " +
                      "firmware: " + getFirmware() + ", " +
                      "product name: " + getProductName() + ", " +
                      "name: " + getName() + ", " +
      src/main/java/net/vrfun/homiecenter/model/SwitchDeviceInfo.java on lines 81..86

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

      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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public ResponseEntity<String> get(@NonNull final String url, @Nullable final Map<String, String> parameters) throws Exception {
              String finalUrl = url;
              if (parameters != null) {
                  String params = "";
                  for (Map.Entry<String, String> entry : parameters.entrySet()) {
      Severity: Minor
      Found in src/main/java/net/vrfun/homiecenter/fritzbox/Requests.java - About 55 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 2 locations. Consider refactoring.
      Open

              try {
                  //validate the url
                  new URL(camera.getUrl());
                  String urlTag = CameraProxyRoutes.getProxyPath() + cameraProxyRoutes.createRouteTag(camera.getUrl()) + "/";
                  camera.setUrlTag(urlTag);
      src/main/java/net/vrfun/homiecenter/service/RestServiceCameraDevice.java on lines 81..88

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

      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

              try {
                  new URL(camera.getPreviewUrl());
                  String urlTag = CameraProxyRoutes.getProxyPath() + cameraProxyRoutes.createRouteTag(camera.getPreviewUrl()) + "/";
                  camera.setPreviewUrlTag(urlTag);
              }
      src/main/java/net/vrfun/homiecenter/service/RestServiceCameraDevice.java on lines 71..79

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

      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 handleDeviceCommand has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public void handleDeviceCommand(long deviceId, @NonNull final String command) throws Exception {
              final String CMD_TEMPERATURE = "temperature=";
              final String CMD_ON = "on";
              final String CMD_OFF = "off";
      
      
      Severity: Minor
      Found in src/main/java/net/vrfun/homiecenter/fritzbox/FRITZBox.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 2 locations. Consider refactoring.
      Open

                  for (Map.Entry<String, String> entry : parameters.entrySet()) {
                      if (!params.isEmpty()) {
                          params += "&";
                      }
                      params += entry.getKey() + "=" + entry.getValue();
      Severity: Minor
      Found in src/main/java/net/vrfun/homiecenter/fritzbox/Requests.java and 1 other location - About 40 mins to fix
      src/main/java/net/vrfun/homiecenter/fritzbox/AuthStatus.java on lines 78..83

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

      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 (Map.Entry<String, String> entry: rights.entrySet()) {
                      if (!rightsString.isEmpty()) {
                          rightsString += ", ";
                      }
                      rightsString += entry.getKey() + ": " + entry.getValue();
      Severity: Minor
      Found in src/main/java/net/vrfun/homiecenter/fritzbox/AuthStatus.java and 1 other location - About 40 mins to fix
      src/main/java/net/vrfun/homiecenter/fritzbox/Requests.java on lines 45..50

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

      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 (!StringUtils.isNullOrEmpty(url) && !url.startsWith("http://") &&
                      !url.startsWith("https://")) {
                  reqCreateCamera.setUrl("http://" + url);
              }
      src/main/java/net/vrfun/homiecenter/service/RestServiceCameraDevice.java on lines 141..144

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

      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 (!StringUtils.isNullOrEmpty(previewUrl) && !previewUrl.startsWith("http://") &&
                      !previewUrl.startsWith("https://")) {
                  reqCreateCamera.setPreviewUrl("http://" + previewUrl);
              }
      src/main/java/net/vrfun/homiecenter/service/RestServiceCameraDevice.java on lines 136..139

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

      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

          @Autowired
          public ApplicationStartup(@NonNull final CameraProxyRoutes cameraProxyRoutes,
                                    @NonNull final UserRepository userRepository,
                                    @NonNull final PasswordEncoder passwordEncoder) {
              this.cameraProxyRoutes = cameraProxyRoutes;
      Severity: Minor
      Found in src/main/java/net/vrfun/homiecenter/ApplicationStartup.java and 1 other location - About 30 mins to fix
      src/main/java/net/vrfun/homiecenter/service/RestServiceCameraDevice.java on lines 46..54

      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

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

                                @NonNull final String role) {
              this.appVersion = appVersion;
              this.name = name;
              this.authenticated = authenticated;
              this.role = role;
      src/main/java/net/vrfun/homiecenter/service/RestServiceUser.java on lines 55..61

      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

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

                                 @NonNull final ApplicationProperties applicationProperties) {
      
              this.userRepository = userRepository;
              this.passwordEncoder = passwordEncoder;
              this.accessUtils = accessUtils;
      src/main/java/net/vrfun/homiecenter/service/comm/RespUserStatus.java on lines 36..41

      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

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

          @Autowired
          public RestServiceCameraDevice(@NonNull final CameraInfoRepository cameraInfoRepository,
                                         @NonNull final CameraProxyRoutes cameraProxyRoutes,
                                         @NonNull final AccessUtils accessUtils) {
      
      
      src/main/java/net/vrfun/homiecenter/ApplicationStartup.java on lines 34..41

      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

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

          @Override
          public String toString() {
              String rightsString = "";
              if (rights != null) {
                  for (Map.Entry<String, String> entry: rights.entrySet()) {
      Severity: Minor
      Found in src/main/java/net/vrfun/homiecenter/fritzbox/AuthStatus.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 collectRights has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private HashMap<String, String> collectRights(@NonNull final Node rightsNode) {
              HashMap<String, String> rights = new HashMap<>();
              Node nextNode = rightsNode.getFirstChild();
              while(nextNode != null) {
                  nextNode = findNextSiblingNode(nextNode, "Name");

      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 edit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          @PostMapping("/api/user/edit")
          public ResponseEntity<HomieCenterUser> edit(@RequestBody ReqUserEdit userEdit, Authentication authentication) {
              Optional<HomieCenterUser> storedUser = userRepository.findById(userEdit.getId());
              if (!storedUser.isPresent()) {
                  return new ResponseEntity<>(HttpStatus.NOT_FOUND);
      Severity: Minor
      Found in src/main/java/net/vrfun/homiecenter/service/RestServiceUser.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