fix: Fix sonar issues (#2925)

* Remove unused member which was also causing a false positive sonar issue.
Fixes sonar issue https://sonarcloud.io/project/issues?open=AY3gHwu5DIZTZkppqVEG&id=iluwatar_java-design-patterns

* Fixes sonar issue https://sonarcloud.io/project/issues?open=AXK0OzDA-CiGJS70dLki&id=iluwatar_java-design-patterns
related to "Refactor the code of the lambda to not have multiple invocations throwing the same checked exception."

Also, updated the code to use Instant and Duration to deal with time instead of int. Added the awaitility
library to perform assertions in test which is more reliable than using Thread.sleep directly to wait for events to happen.

* checkstyle fix

* Add sneaky throws to fix sonar lint issue. This is fine as the newFile method is not being tested but instead the new SimpleFileWriter(...) is.

* The first booking needs to happen outside the assertions. Fixed other warnings

* Use records to pass around related objects instead of using a large number of
individual params, which sonar did not like.

* Checkstyle fixes

* checkstyle fixes

* Remove complexity to keep sonar happy.

* Split into different methods to reduce complexity. Could be broken down even further but currently Sonar is happy.

* Move files to correct package

* Add valid assertions to tests

* rename constants to avoid confusion

* Sonar warning related to cognitive complexity can be suppressed as the methods are quite generic and not functional enough to be separated out.

* Use constants to keep Sonar happy

* Use correct constant naming conventions

* Use correct constant naming conventions

* Use lombok to define noargsconstructor

* Use a single method to do the logging

* Remove unused constructor and redundant method

* Use a reusable method for logging
This commit is contained in:
k1w1dev
2024-05-04 17:20:01 +12:00
committed by GitHub
parent 5e12bc588a
commit ef42e169b9
46 changed files with 571 additions and 554 deletions
@@ -24,21 +24,19 @@
*/
package com.iluwatar.page.controller;
import lombok.Getter;
import lombok.Setter;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;
/**
* ignup model.
*/
@Component
@Getter
@Setter
@Data
@NoArgsConstructor
public class SignupModel {
private String name;
private String email;
private String password;
public SignupModel() {
}
}
}
@@ -24,15 +24,15 @@
*/
package com.iluwatar.page.controller;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* Signup View.
*/
@Slf4j
@NoArgsConstructor
public class SignupView {
public SignupView() {
}
public String display() {
LOGGER.info("display signup front page");
@@ -46,4 +46,4 @@ public class SignupView {
LOGGER.info("Redirect to user page with " + "name " + form.getName() + " email " + form.getEmail());
return "redirect:/user";
}
}
}
@@ -24,6 +24,7 @@
*/
package com.iluwatar.page.controller;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -34,11 +35,10 @@ import org.springframework.web.bind.annotation.GetMapping;
*/
@Slf4j
@Controller
@NoArgsConstructor
public class UserController {
private final UserView view = new UserView();
public UserController() {}
/**
* Handle http GET request and access view and model.
*/
@@ -48,4 +48,4 @@ public class UserController {
model.addAttribute("email", form.getEmail());
return view.display(form);
}
}
}
@@ -24,17 +24,16 @@
*/
package com.iluwatar.page.controller;
import lombok.Getter;
import lombok.Setter;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* User model.
*/
@Getter
@Setter
@Data
@NoArgsConstructor
public class UserModel {
private String name;
private String email;
public UserModel() {}
}
}