Removed confusing aliases
This commit is contained in:
parent
de30b3f638
commit
0824c8f059
9 changed files with 35 additions and 44 deletions
|
@ -2,10 +2,10 @@
|
||||||
<SmellBaseline>
|
<SmellBaseline>
|
||||||
<ManuallySuppressedIssues/>
|
<ManuallySuppressedIssues/>
|
||||||
<CurrentIssues>
|
<CurrentIssues>
|
||||||
<ID>ComplexMethod:JokeApi.kt$fun getRawJokes( categories: Set<Category> = setOf(Category.ANY), language: Language = Language.ENGLISH, flags: Set<Flag> = emptySet(), type: Type = Type.ALL, format: Format = Format.JSON, search: String = "", idRange: IdRange = IdRange(), amount: Int = 1, safe: Boolean = false, auth: String = "" ): String</ID>
|
<ID>ComplexMethod:JokeApi.kt$fun getRawJokes( categories: Set<Category> = setOf(Category.ANY), language: Language = Language.EN, flags: Set<Flag> = emptySet(), type: Type = Type.ALL, format: Format = Format.JSON, search: String = "", idRange: IdRange = IdRange(), amount: Int = 1, safe: Boolean = false, auth: String = "" ): String</ID>
|
||||||
<ID>LongParameterList:JokeApi.kt$( amount: Int, categories: Set<Category> = setOf(Category.ANY), language: Language = Language.ENGLISH, flags: Set<Flag> = emptySet(), type: Type = Type.ALL, search: String = "", idRange: IdRange = IdRange(), safe: Boolean = false, splitNewLine: Boolean = false, auth: String = "" )</ID>
|
<ID>LongParameterList:JokeApi.kt$( amount: Int, categories: Set<Category> = setOf(Category.ANY), language: Language = Language.EN, flags: Set<Flag> = emptySet(), type: Type = Type.ALL, search: String = "", idRange: IdRange = IdRange(), safe: Boolean = false, splitNewLine: Boolean = false, auth: String = "" )</ID>
|
||||||
<ID>LongParameterList:JokeApi.kt$( categories: Set<Category> = setOf(Category.ANY), language: Language = Language.ENGLISH, flags: Set<Flag> = emptySet(), type: Type = Type.ALL, format: Format = Format.JSON, search: String = "", idRange: IdRange = IdRange(), amount: Int = 1, safe: Boolean = false, auth: String = "" )</ID>
|
<ID>LongParameterList:JokeApi.kt$( categories: Set<Category> = setOf(Category.ANY), language: Language = Language.EN, flags: Set<Flag> = emptySet(), type: Type = Type.ALL, format: Format = Format.JSON, search: String = "", idRange: IdRange = IdRange(), amount: Int = 1, safe: Boolean = false, auth: String = "" )</ID>
|
||||||
<ID>LongParameterList:JokeApi.kt$( categories: Set<Category> = setOf(Category.ANY), language: Language = Language.ENGLISH, flags: Set<Flag> = emptySet(), type: Type = Type.ALL, search: String = "", idRange: IdRange = IdRange(), safe: Boolean = false, splitNewLine: Boolean = false, auth: String = "" )</ID>
|
<ID>LongParameterList:JokeApi.kt$( categories: Set<Category> = setOf(Category.ANY), language: Language = Language.EN, flags: Set<Flag> = emptySet(), type: Type = Type.ALL, search: String = "", idRange: IdRange = IdRange(), safe: Boolean = false, splitNewLine: Boolean = false, auth: String = "" )</ID>
|
||||||
<ID>LongParameterList:JokeConfig.kt$JokeConfig$( val categories: Set<Category>, val language: Language, val flags: Set<Flag>, val type: Type, val format: Format, val search: String, val idRange: IdRange, val amount: Int, val safe: Boolean, val splitNewLine: Boolean, val auth: String )</ID>
|
<ID>LongParameterList:JokeConfig.kt$JokeConfig$( val categories: Set<Category>, val language: Language, val flags: Set<Flag>, val type: Type, val format: Format, val search: String, val idRange: IdRange, val amount: Int, val safe: Boolean, val splitNewLine: Boolean, val auth: String )</ID>
|
||||||
<ID>LongParameterList:JokeException.kt$JokeException$( val internalError: Boolean, val code: Int, message: String, val causedBy: List<String>, val additionalInfo: String, val timestamp: Long, cause: Throwable? = null )</ID>
|
<ID>LongParameterList:JokeException.kt$JokeException$( val internalError: Boolean, val code: Int, message: String, val causedBy: List<String>, val additionalInfo: String, val timestamp: Long, cause: Throwable? = null )</ID>
|
||||||
<ID>MagicNumber:util.kt$200</ID>
|
<ID>MagicNumber:util.kt$200</ID>
|
||||||
|
|
|
@ -179,7 +179,7 @@ class JokeApi private constructor() {
|
||||||
*/
|
*/
|
||||||
fun getJoke(
|
fun getJoke(
|
||||||
categories: Set<Category> = setOf(Category.ANY),
|
categories: Set<Category> = setOf(Category.ANY),
|
||||||
language: Language = Language.ENGLISH,
|
language: Language = Language.EN,
|
||||||
flags: Set<Flag> = emptySet(),
|
flags: Set<Flag> = emptySet(),
|
||||||
type: Type = Type.ALL,
|
type: Type = Type.ALL,
|
||||||
search: String = "",
|
search: String = "",
|
||||||
|
@ -218,7 +218,7 @@ fun getJoke(
|
||||||
fun getJokes(
|
fun getJokes(
|
||||||
amount: Int,
|
amount: Int,
|
||||||
categories: Set<Category> = setOf(Category.ANY),
|
categories: Set<Category> = setOf(Category.ANY),
|
||||||
language: Language = Language.ENGLISH,
|
language: Language = Language.EN,
|
||||||
flags: Set<Flag> = emptySet(),
|
flags: Set<Flag> = emptySet(),
|
||||||
type: Type = Type.ALL,
|
type: Type = Type.ALL,
|
||||||
search: String = "",
|
search: String = "",
|
||||||
|
@ -259,7 +259,7 @@ fun getJokes(
|
||||||
*/
|
*/
|
||||||
fun getRawJokes(
|
fun getRawJokes(
|
||||||
categories: Set<Category> = setOf(Category.ANY),
|
categories: Set<Category> = setOf(Category.ANY),
|
||||||
language: Language = Language.ENGLISH,
|
language: Language = Language.EN,
|
||||||
flags: Set<Flag> = emptySet(),
|
flags: Set<Flag> = emptySet(),
|
||||||
type: Type = Type.ALL,
|
type: Type = Type.ALL,
|
||||||
format: Format = Format.JSON,
|
format: Format = Format.JSON,
|
||||||
|
@ -272,14 +272,14 @@ fun getRawJokes(
|
||||||
val params = mutableMapOf<String, String>()
|
val params = mutableMapOf<String, String>()
|
||||||
|
|
||||||
// Categories
|
// Categories
|
||||||
val path = if (!categories.contains(Category.ANY)) {
|
val path = if (categories.isEmpty() || categories.contains(Category.ANY)) {
|
||||||
categories.stream().map(Category::value).collect(Collectors.joining(","))
|
|
||||||
} else {
|
|
||||||
Category.ANY.value
|
Category.ANY.value
|
||||||
|
} else {
|
||||||
|
categories.stream().map(Category::value).collect(Collectors.joining(","))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
if (language != Language.ENGLISH) {
|
if (language != Language.EN) {
|
||||||
params[Parameter.LANG] = language.value
|
params[Parameter.LANG] = language.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class JokeConfig private constructor(
|
||||||
*/
|
*/
|
||||||
data class Builder(
|
data class Builder(
|
||||||
var categories: Set<Category> = setOf(Category.ANY),
|
var categories: Set<Category> = setOf(Category.ANY),
|
||||||
var language: Language = Language.ENGLISH,
|
var language: Language = Language.EN,
|
||||||
var flags: Set<Flag> = emptySet(),
|
var flags: Set<Flag> = emptySet(),
|
||||||
var type: Type = Type.ALL,
|
var type: Type = Type.ALL,
|
||||||
var format: Format = Format.JSON,
|
var format: Format = Format.JSON,
|
||||||
|
|
|
@ -33,22 +33,14 @@
|
||||||
package net.thauvin.erik.jokeapi.models
|
package net.thauvin.erik.jokeapi.models
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The supported [categories and aliases](https://jokeapi.dev/#categories), use [ANY] for all.
|
* The supported [categories](https://jokeapi.dev/#categories), use [ANY] for all.
|
||||||
*/
|
*/
|
||||||
enum class Category(val value: String) {
|
enum class Category(val value: String) {
|
||||||
ANY("Any"),
|
ANY("Any"),
|
||||||
CHRISTMAS("Christmas"),
|
CHRISTMAS("Christmas"),
|
||||||
DARK("Dark"),
|
DARK("Dark"),
|
||||||
|
|
||||||
MISC("Misc"),
|
MISC("Misc"),
|
||||||
MISCELLANEOUS(MISC.value),
|
|
||||||
|
|
||||||
PROGRAMMING("Programming"),
|
PROGRAMMING("Programming"),
|
||||||
CODING(PROGRAMMING.value),
|
|
||||||
DEVELOPMENT(PROGRAMMING.value),
|
|
||||||
|
|
||||||
PUN("Pun"),
|
PUN("Pun"),
|
||||||
|
SPOOKY("Spooky")
|
||||||
SPOOKY("Spooky"),
|
|
||||||
HALLOWEEN(SPOOKY.value)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ package net.thauvin.erik.jokeapi.models
|
||||||
* The supported [blacklist flags](https://jokeapi.dev/#flags-param), use [ALL] to prevent all.
|
* The supported [blacklist flags](https://jokeapi.dev/#flags-param), use [ALL] to prevent all.
|
||||||
*/
|
*/
|
||||||
enum class Flag(val value: String) {
|
enum class Flag(val value: String) {
|
||||||
|
EXPLICIT("explicit"),
|
||||||
NSFW("nsfw"),
|
NSFW("nsfw"),
|
||||||
RELIGIOUS("religious"),
|
|
||||||
POLITICAL("political"),
|
POLITICAL("political"),
|
||||||
RACIST("racist"),
|
RACIST("racist"),
|
||||||
|
RELIGIOUS("religious"),
|
||||||
SEXIST("sexist"),
|
SEXIST("sexist"),
|
||||||
EXPLICIT("explicit"),
|
|
||||||
ALL("${NSFW.value},${RELIGIOUS.value},${POLITICAL.value},${RACIST.value},${SEXIST.value},${EXPLICIT.value}")
|
ALL("${NSFW.value},${RELIGIOUS.value},${POLITICAL.value},${RACIST.value},${SEXIST.value},${EXPLICIT.value}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,5 +36,9 @@ package net.thauvin.erik.jokeapi.models
|
||||||
* The supported response [formats](https://jokeapi.dev/#format-param).
|
* The supported response [formats](https://jokeapi.dev/#format-param).
|
||||||
*/
|
*/
|
||||||
enum class Format(val value: String) {
|
enum class Format(val value: String) {
|
||||||
JSON("json"), XML("xml"), YAML("yaml"), TEXT("txt"), TXT(TEXT.value)
|
JSON("json"),
|
||||||
|
/** Plain Text */
|
||||||
|
TXT("txt"),
|
||||||
|
XML("xml"),
|
||||||
|
YAML("yaml")
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,21 +36,16 @@ package net.thauvin.erik.jokeapi.models
|
||||||
* The supported [languages](https://jokeapi.dev/#lang).
|
* The supported [languages](https://jokeapi.dev/#lang).
|
||||||
*/
|
*/
|
||||||
enum class Language(val value: String) {
|
enum class Language(val value: String) {
|
||||||
ENGLISH("en"),
|
/** Czech */
|
||||||
EN(ENGLISH.value),
|
CS("cs"),
|
||||||
|
/** German */
|
||||||
CZECH("cs"),
|
DE("de"),
|
||||||
CS(CZECH.value),
|
/** English */
|
||||||
|
EN("en"),
|
||||||
GERMAN("de"),
|
/** Spanish */
|
||||||
DE(GERMAN.value),
|
ES("es"),
|
||||||
|
/** French */
|
||||||
SPANISH("es"),
|
FR("fr"),
|
||||||
ES(SPANISH.value),
|
/** Portuguese */
|
||||||
|
PT("pt")
|
||||||
FRENCH("fr"),
|
|
||||||
FR(FRENCH.value),
|
|
||||||
|
|
||||||
PORTUGUESE("pt"),
|
|
||||||
PT(PORTUGUESE.value)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ import kotlin.test.assertContains
|
||||||
internal class GetRawJokesTest {
|
internal class GetRawJokesTest {
|
||||||
@Test
|
@Test
|
||||||
fun `Get Raw Joke with TXT`() {
|
fun `Get Raw Joke with TXT`() {
|
||||||
val response = getRawJokes(format = Format.TEXT)
|
val response = getRawJokes(format = Format.TXT)
|
||||||
assertThat(response, "getRawJoke(txt)").all {
|
assertThat(response, "getRawJoke(txt)").all {
|
||||||
isNotEmpty()
|
isNotEmpty()
|
||||||
doesNotContain("Error")
|
doesNotContain("Error")
|
||||||
|
|
|
@ -112,7 +112,7 @@ class JokeConfigTest {
|
||||||
fun `Get Raw Joke with Builder`() {
|
fun `Get Raw Joke with Builder`() {
|
||||||
val config = JokeConfig.Builder().apply {
|
val config = JokeConfig.Builder().apply {
|
||||||
categories(setOf(Category.PROGRAMMING))
|
categories(setOf(Category.PROGRAMMING))
|
||||||
format(Format.TEXT)
|
format(Format.TXT)
|
||||||
search("bar")
|
search("bar")
|
||||||
amount(2)
|
amount(2)
|
||||||
safe(true)
|
safe(true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue