Skip to content

Commit ef9b305

Browse files
Fix SonarQube hotspots
1 parent c9d77ac commit ef9b305

File tree

3 files changed

+38
-37
lines changed

3 files changed

+38
-37
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ WORKDIR /
55
COPY / .
66

77
ENV SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}
8+
ENV SPRING_PROFILES_ACTIVE=dev
89

910
RUN ./gradlew --no-daemon clean build
1011

build.gradle.kts

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ plugins {
55
id("com.github.johnrengelman.shadow") version "8.1.1"
66
id("com.github.ben-manes.versions") version "0.52.0"
77
id("org.springframework.boot") version "3.5.6"
8-
// id("org.springframework.boot") version "3.5.8"
9-
// id("org.springframework.boot") version "4.0.0"
108
id("org.springdoc.openapi-gradle-plugin") version "1.9.0"
119
id("io.spring.dependency-management") version "1.1.7"
1210
id("org.sonarqube") version "7.0.1.6134"
@@ -30,55 +28,62 @@ java {
3028

3129
repositories {
3230
mavenCentral()
33-
// maven { url = uri("https://repo.spring.io/milestone") }
34-
// maven { url = uri("https://repo.spring.io/snapshot") }
3531
}
3632

33+
val datafakerVer = "2.5.3"
34+
val lombokVer = "1.18.38"
35+
val webMVCuiVer = "2.8.13"
36+
val jacksonNullableVer = "0.2.6"
37+
val mapstructVer = "1.5.5.Final"
38+
val HikariCPVer = "6.3.0"
39+
val postgresqlVer = "42.7.7"
40+
val lmMapstructBndVer = "0.2.0"
41+
val assertjVer = "4.1.1"
42+
val instancioVer = "5.5.1"
43+
3744
dependencies {
3845
implementation("org.springframework.boot:spring-boot-starter")
39-
// implementation("org.springframework.boot:spring-boot-starter:4.0.0")
4046
implementation("org.springframework.boot:spring-boot-starter-web")
4147
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
4248
implementation("org.springframework.boot:spring-boot-starter-validation")
4349
implementation("org.springframework.boot:spring-boot-starter-security")
4450
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
4551
implementation("org.springframework.boot:spring-boot-devtools")
4652
//
47-
implementation("net.datafaker:datafaker:2.5.3")
48-
// SpringDoc OpenAPI Starter WebMVC UI » 2.8.13
49-
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.13")
53+
implementation("net.datafaker:datafaker:$datafakerVer")
54+
// SpringDoc OpenAPI Starter WebMVC UI
55+
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:$webMVCuiVer")
5056
// модуль jackson-databind-nullable
51-
implementation("org.openapitools:jackson-databind-nullable:0.2.6")
57+
implementation("org.openapitools:jackson-databind-nullable:$jacksonNullableVer")
5258
// Mapstruct
53-
implementation("org.mapstruct:mapstruct:1.5.5.Final")
59+
implementation("org.mapstruct:mapstruct:$mapstructVer")
60+
// DataBase section
61+
implementation("com.zaxxer:HikariCP:$HikariCPVer")
62+
runtimeOnly("com.h2database:h2") // database H2 & HikariCP
63+
implementation("org.postgresql:postgresql:$postgresqlVer")
64+
5465
// конфиг Mapstruct не работает с классами, в которых используется lombok
5566
// https://ru.stackoverflow.com/questions/1286369
56-
compileOnly("org.projectlombok:lombok:1.18.38")
57-
compileOnly("org.mapstruct:mapstruct:1.5.5.Final")
58-
annotationProcessor("org.projectlombok:lombok-mapstruct-binding:0.2.0")
59-
annotationProcessor("org.mapstruct:mapstruct-processor:1.5.5.Final")
60-
annotationProcessor("org.projectlombok:lombok:1.18.38")
61-
// DataBase section
62-
implementation("com.zaxxer:HikariCP:6.3.0")
63-
runtimeOnly("com.h2database:h2")
64-
implementation("com.h2database:h2:") // database H2 & HikariCP
65-
// for driver class: org.postgresql.Driver
66-
runtimeOnly("org.postgresql:postgresql")
67-
implementation("org.postgresql:postgresql:42.7.7")
67+
compileOnly("org.projectlombok:lombok:$lombokVer")
68+
compileOnly("org.mapstruct:mapstruct:$mapstructVer")
69+
annotationProcessor("org.projectlombok:lombok-mapstruct-binding:$lmMapstructBndVer")
70+
annotationProcessor("org.mapstruct:mapstruct-processor:$mapstructVer")
71+
annotationProcessor("org.projectlombok:lombok:$lombokVer")
72+
6873
// *** Tests ***
69-
testCompileOnly("org.projectlombok:lombok:1.18.38")
70-
testAnnotationProcessor("org.projectlombok:lombok:1.18.38")
71-
testAnnotationProcessor("org.mapstruct:mapstruct-processor:1.5.5.Final")
74+
testCompileOnly("org.projectlombok:lombok:$lombokVer")
75+
testAnnotationProcessor("org.projectlombok:lombok:$lombokVer")
76+
testAnnotationProcessor("org.mapstruct:mapstruct-processor:$mapstructVer")
7277
//
7378
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
7479
// стартёр тестов
7580
testImplementation("org.springframework.boot:spring-boot-starter-test")
7681
// для аутентификации
7782
testImplementation("org.springframework.security:spring-security-test")
7883
// test JSON struct
79-
testImplementation("net.javacrumbs.json-unit:json-unit-assertj:4.1.1")
84+
testImplementation("net.javacrumbs.json-unit:json-unit-assertj:$assertjVer")
8085
// Instacio
81-
testImplementation("org.instancio:instancio-junit:5.5.1")
86+
testImplementation("org.instancio:instancio-junit:$instancioVer")
8287
}
8388

8489
checkstyle {

src/main/java/hexlet/code/config/SecurityConfig.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
@Configuration
2424
@EnableWebSecurity
2525
@EnableMethodSecurity
26-
//@EnableMethodSecurity(prePostEnabled = true)
2726
public class SecurityConfig {
2827
private final JwtDecoder jwtDecoder;
2928
private final PasswordEncoder passwordEncoder;
@@ -48,10 +47,9 @@ public SecurityConfig(JwtDecoder jwtDecoder,
4847
@Bean
4948
public SecurityFilterChain securityFilterChain(HttpSecurity http, HandlerMappingIntrospector introspector)
5049
throws Exception {
51-
// По умолчанию все запрещено
5250
return http
5351
.csrf(csrf -> csrf.disable())
54-
.authorizeHttpRequests(auth -> auth
52+
.authorizeHttpRequests(auth -> auth // По умолчанию все запрещено
5553
// general
5654
.requestMatchers("/").permitAll()
5755
.requestMatchers("/api/login").permitAll()
@@ -83,17 +81,14 @@ public AuthenticationManager authenticationManager(HttpSecurity http) throws Exc
8381
.build();
8482
}
8583

84+
8685
/**
87-
*
88-
* @param passwordEncoder
89-
* @param userService
86+
* @param auth
9087
* @return AuthenticationProvider
9188
*/
9289
@Bean
93-
public AuthenticationProvider daoAuthProvider(PasswordEncoder passwordEncoder,
94-
CustomUserDetailsService userService) {
95-
var provider = new DaoAuthenticationProvider();
96-
provider.setUserDetailsService(userService);
90+
public AuthenticationProvider daoAuthProvider(AuthenticationManagerBuilder auth) {
91+
var provider = new DaoAuthenticationProvider(userService);
9792
provider.setPasswordEncoder(passwordEncoder);
9893
return provider;
9994
}

0 commit comments

Comments
 (0)