Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint warnings #257

Merged
merged 6 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<div align="center">
<a href="https://khipster.dev">
<img width="320" height="160" src="https://raw.githubusercontent.com/jhipster/jhipster-kotlin/master/logo-khipster.png">
</a>
<a href="https://khipster.dev">
<img width="320" height="160" src="https://raw.githubusercontent.com/jhipster/jhipster-kotlin/master/logo-khipster.png">
</a>
</div>

---

# About

<div align="center">
<a href="https://khipster.dev">
<img width="500" height="98" src="https://raw.githubusercontent.com/sendilkumarn/jhipster-kotlin-artwork/master/about-project.png">
</a>
<a href="https://khipster.dev">
<img width="500" height="98" src="https://raw.githubusercontent.com/sendilkumarn/jhipster-kotlin-artwork/master/about-project.png">
</a>
</div>

> JHipster is a development platform to quickly generate, develop, and deploy modern web applications and microservice architectures. We support many frontend technologies, including Angular, React, and Vue. We even have mobile app support for Ionic and React Native! On the backend, we support Spring Boot (with Java or Kotlin), Micronaut, Quarkus, Node.js, and .NET. For deployment, we embrace cloud native principles with Docker and Kubernetes. Deployment support exists for AWS, Azure, Cloud Foundry, Google Cloud Platform, Heroku, and OpenShift.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-%>
<%# Returns a string of all validator annotations for the entity field. -%>
<%# Returns a string of all validator annotations for the entity field. -%>
<%
const field = fields[idx];
let result = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-%>
<%# Returns a string of all validator annotations for the entity relationships. -%>
<%# Returns a string of all validator annotations for the entity relationships. -%>
<%
const relationship = relationships[idx];
let result = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ relationships.forEach((relationship, index) => {
}); _%>
<%_ if (relationships.length !== 0 && renMapAnotEnt === true) { _%>
@Mappings(
<%- entityToDTOMapping.join(',\n\t\t') %>
<%- entityToDTOMapping.join(',\n ') %>
)
<%_ } _%>
<%_ if (renMapAnotEnt === true) { _%>
Expand Down Expand Up @@ -120,7 +120,7 @@ relationships.forEach((relationship, index) => {
}); _ %>
<%_ if (relationships.length !== 0 && renMapAnotEnt === true) { _%>
@Mappings(
<%- dtoToEntityMapping.join(',\n\t\t') %>
<%- dtoToEntityMapping.join(',\n ') %>
)
<%_ } _%>
override fun toEntity(<%= asDto(entityInstance) %>: <%= asDto(entityClass) %>): <%= asEntity(entityClass) %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,16 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>: Ab
@BeforeEach
fun setup() {
MockitoAnnotations.initMocks(this)
<%_ if (service !== 'no') { _%>
val <%= entityInstance %>Resource = <%= entityClass %>Resource(<%= entityInstance %>Service<% if (jpaMetamodelFiltering) { %>, <%= entityInstance %>QueryService<% } %><% if (saveUserSnapshot) { %>, userRepository<% } %>)
<%_ } else { _%>
val <%= entityInstance %>Resource = <%= entityClass %>Resource(<%= entityInstance %>Repository<% if (dto === 'mapstruct') { %>, <%= entityInstance %>Mapper<% } %><% if (searchEngine === 'elasticsearch') { %>, mock<%= entityClass %>SearchRepository<% } %><% if (saveUserSnapshot) { %>, userRepository<% } %><% if (isUsingMapsId === true && dto !== 'mapstruct') { %>, <%= mapsIdRepoInstance _%> <% } %>)
<%_ } _%>
this.rest<%= entityClass %>MockMvc = MockMvcBuilders.standaloneSetup(<%= entityInstance %>Resource)
.setCustomArgumentResolvers(pageableArgumentResolver)
.setControllerAdvice(exceptionTranslator)
.setConversionService(createFormattingConversionService())
.setMessageConverters(jacksonMessageConverter)
<%_ if (service !== 'no') { _%>
val <%= entityInstance %>Resource = <%= entityClass %>Resource(<%= entityInstance %>Service<% if (jpaMetamodelFiltering) { %>, <%= entityInstance %>QueryService<% } %><% if (saveUserSnapshot) { %>, userRepository<% } %>)
<%_ } else { _%>
val <%= entityInstance %>Resource = <%= entityClass %>Resource(<%= entityInstance %>Repository<% if (dto === 'mapstruct') { %>, <%= entityInstance %>Mapper<% } %><% if (searchEngine === 'elasticsearch') { %>, mock<%= entityClass %>SearchRepository<% } %><% if (saveUserSnapshot) { %>, userRepository<% } %><% if (isUsingMapsId === true && dto !== 'mapstruct') { %>, <%= mapsIdRepoInstance _%> <% } %>)
<%_ } _%>
this.rest<%= entityClass %>MockMvc = MockMvcBuilders.standaloneSetup(<%= entityInstance %>Resource)
.setCustomArgumentResolvers(pageableArgumentResolver)
.setControllerAdvice(exceptionTranslator)
.setConversionService(createFormattingConversionService())
.setMessageConverters(jacksonMessageConverter)
.setValidator(validator).build()
}
<%_ } _%>
Expand Down
2 changes: 1 addition & 1 deletion generators/generator-kotlin-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
const KOTLIN_VERSION = '1.3.70';
const MOCKITO_KOTLIN_VERSION = '2.2.0';
const KTLINT_MAVEN_VERSION = '1.2.2';
const KTLINT_GRADLE_VERSION = '9.0.0';
const KTLINT_GRADLE_VERSION = '9.4.0';
const DETEKT_VERSION = '1.1.0';
const MAVEN_ANTRUN_VERSION = '1.8';

Expand Down
7 changes: 4 additions & 3 deletions generators/server/templates/gradle/kotlin.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ allOpen {

[compileKotlin, compileTestKotlin]*.with {
kotlinOptions {
jvmTarget = "<%= JAVA_VERSION %>"
jvmTarget = "<%= JAVA_VERSION %>"
javaParameters = true
freeCompilerArgs = ["-Xjvm-default=enable"]
freeCompilerArgs = ["-Xjvm-default=enable"]
}
}

ktlint {
//See more options: https://github.com/JLLeitschuh/ktlint-gradle#configuration
ignoreFailures = true
ignoreFailures = false
disabledRules = ["no-wildcard-imports", "filename"]
}

detekt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfigurati
import org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration
import org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties
<%_ } _%>
import org.springframework.context.annotation.*
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.ComponentScan.Filter
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.FilterType
import org.springframework.context.annotation.Import
import org.springframework.context.annotation.Profile
<%_ if (databaseType === 'mongodb' || databaseType === 'couchbase' || (databaseType === 'sql' && reactive)) { _%>
import org.springframework.core.convert.converter.Converter
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,14 @@ class SecurityConfiguration(private val oAuth2Properties: OAuth2Properties<% if
override fun configure(http: HttpSecurity) {
http
.csrf()
<%_ if (applicationType === 'gateway') { _%>
<%_ if (applicationType === 'gateway') { _%>
.ignoringAntMatchers("/h2-console/**")
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.and()
.addFilterBefore(corsFilter, CsrfFilter::class.java)
<%_ } else { _%>
<%_ } else { _%>
.disable()
<%_ } _%>
<%_ } _%>
.headers()
.frameOptions()
.disable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ class PersistentTokenRememberMeServices(
if (token.tokenDate!!.plusDays(TOKEN_VALIDITY_DAYS.toLong()).isBefore(LocalDate.now())) {
<%_ } _%>
<%_ if (databaseType === 'cassandra') { _%>
if (token.tokenDate!!.toInstant().plus(
TOKEN_VALIDITY_DAYS.toLong(), ChronoUnit.DAYS
).isBefore(Date().toInstant())
if (token.tokenDate!!.toInstant()
.plus(TOKEN_VALIDITY_DAYS.toLong(), ChronoUnit.DAYS)
.isBefore(Date().toInstant())
) {
<%_ } _%>
<%_ if (databaseType === 'sql') { _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,25 @@ fun isAuthenticated(): <% if (!reactive) { %>Boolean<% } else { %>Mono<Boolean><
*/
fun isCurrentUserInRole(authority: String): <% if (!reactive) { %>Boolean<% } else { %>Mono<Boolean><% } %> {
<%_ if (!reactive) { _%>
val authentication = SecurityContextHolder.getContext().authentication
val authentication = SecurityContextHolder.getContext().authentication

if (authentication != null) {
val isUserPresent = getAuthorities(authentication)?.any { it == authority }
if(isUserPresent != null) {
return isUserPresent
if (authentication != null) {
val isUserPresent = getAuthorities(authentication)?.any { it == authority }
if(isUserPresent != null) {
return isUserPresent
}
}
}

return false
return false
<%_ } else { _%>
return ReactiveSecurityContextHolder.getContext()
.map(SecurityContext::getAuthentication)
.map(Authentication::getAuthorities)
.map {
it
.map(GrantedAuthority::getAuthority)
.any { it == authority }
}
return ReactiveSecurityContextHolder.getContext()
.map(SecurityContext::getAuthentication)
.map(Authentication::getAuthorities)
.map {
it
.map(GrantedAuthority::getAuthority)
.any { it == authority }
}
<%_ } _%>
}

Expand Down