Skip to content

Commit

Permalink
fix codesmell and update some rules on detekt
Browse files Browse the repository at this point in the history
  • Loading branch information
muhrifqii committed Jan 1, 2024
1 parent 6de6484 commit 39ba1e2
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 11 deletions.
4 changes: 4 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,9 @@ style:
max: 3
PreferToOverPairSyntax:
active: true
UnnecessaryAbstractClass:
active: true
excludes: *excludedDirs

formatting:
excludes: *excludedDirs
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx5g -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=false
kotlin.code.style=official
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ agp = "8.2.0"
appcompat = "1.6.1"
constraintlayout = "2.1.4"
core-ktx = "1.12.0"
detekt = "1.20.0-RC2"
detekt = "1.23.4"
espresso-core = "3.5.1"
fuel = "2.3.1"
junit = "4.13.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class ParserExecutor<T>(
if (element.name != RSSVersion.RSS_V1.elementName &&
element.name != RSSVersion.RSS_V2.elementName &&
element.name != RSSVersion.RSS_ATOM.elementName
) return element
) {
return element
}
val attrCount = parser.attributeCount
for (i in 0 until attrCount) {
val attribute = parser.getRSSAttributeElement(i, pullParserNSAware)
Expand Down Expand Up @@ -186,10 +188,11 @@ class ParserExecutor<T>(
ParseRSSKeyword.LINK -> mode[LinkEnabledObject::class.java] = {
val rel = parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_REL) ?: ""
val href = parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_HREF)
if (rel == "self" && it is RSSFeed)
if (rel == "self" && it is RSSFeed) {
it.link = href
else if (rel == "alternate" && it is RSSItem)
} else if (rel == "alternate" && it is RSSItem) {
it.link = href
}
}
ParseRSSKeyword.RIGHTS -> mode[CopyrightsEnabledObject::class.java] = {
it?.copyright = parser.nextTextTrimmed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ sealed class ParsingMode(val nameToken: String) : ParsingModeOperation {
is Read -> return
is MediaNS.Group -> {
val item = modes.lastValue()
if (item !is Item) throw ParseRSSException(
"Error ${other.nameToken} should be under the item element",
)
if (item !is Item) {
throw ParseRSSException(
"Error ${other.nameToken} should be under the item element",
)
}
other.rssObject = item.rssObject
}
is Author -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ParseRSSConverterFactory<R : RSSFeed> private constructor() : Converter.Fa
annotations: Array<Annotation>,
retrofit: Retrofit
): Converter<ResponseBody, *> {

return ParseRSSConverter<R>()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package com.github.muhrifqii.parserss.sample

import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import org.junit.Assert.assertEquals

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.github.muhrifqii.parserss.sample

import org.junit.Assert.assertEquals
import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
Expand Down

0 comments on commit 39ba1e2

Please sign in to comment.