Skip to content

Commit df25091

Browse files
author
Simon Schubert
committed
Spotless
1 parent fc96666 commit df25091

10 files changed

Lines changed: 363 additions & 408 deletions

File tree

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/IconResources.kt

Lines changed: 256 additions & 260 deletions
Large diffs are not rendered by default.

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/ui/screens/basicgroups/BasicGroupsViewModel.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class BasicGroupsViewModel(categoryId: Long) : ViewModel() {
2525

2626
var basicGroups = databaseHelper.getBasicGroups(categoryId)
2727

28-
fun isGroupCollapsed(id: Long): Boolean {
29-
return collapsedMap[id] == true
30-
}
28+
fun isGroupCollapsed(id: Long): Boolean = collapsedMap[id] == true
3129

3230
fun toggleCollapse(id: Long) {
3331
collapsedMap[id] = !collapsedMap.getOrDefault(id, false)

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/ui/screens/commanddetail/CommandDetailViewModel.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ class CommandDetailViewModel(commandId: Long) : ViewModel() {
2626

2727
var sections = databaseHelper.getSections(commandId).sortedBy { it.getSortPriority() }
2828

29-
fun isGroupCollapsed(id: Long): Boolean {
30-
return collapsedMap[id] == true
31-
}
29+
fun isGroupCollapsed(id: Long): Boolean = collapsedMap[id] == true
3230

3331
fun toggleCollapse(id: Long) {
3432
collapsedMap[id] = !collapsedMap.getOrDefault(id, false)

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/ui/screens/commandlist/CommandListViewModel.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,5 @@ class CommandListViewModel(val preferenceUtil: PreferenceUtil) : ViewModel() {
4242
)
4343
}
4444

45-
fun hasBookmark(id: Long): Boolean {
46-
return preferenceUtil.hasBookmark(id)
47-
}
45+
fun hasBookmark(id: Long): Boolean = preferenceUtil.hasBookmark(id)
4846
}

android/src/main/java/com/inspiredandroid/linuxcommandbibliotheca/ui/screens/tips/TipsViewModel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import databases.Tip
88

99
sealed class TipSectionElement {
1010
data class Text(val text: String) : TipSectionElement()
11-
data class Code(val command: String, val elements: List<CommandElement>) :
12-
TipSectionElement()
11+
data class Code(val command: String, val elements: List<CommandElement>) : TipSectionElement()
1312

1413
data class NestedCode(
1514
val text: String,

cli/src/main/kotlin/com/linuxcommandlibrary/cli/ConsoleApplication.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,4 @@ fun printTipData(data: String) {
184184
println(data.replace("\\n", "").replace("<b>", BOLD).replace("</b>", RESET))
185185
}
186186

187-
fun readNumber(): Int {
188-
return readlnOrNull()?.toIntOrNull() ?: -1
189-
}
187+
fun readNumber(): Int = readlnOrNull()?.toIntOrNull() ?: -1

common/src/cliMain/kotlin/com/linuxcommandlibrary/shared/Platform.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ import java.io.File
2020
* limitations under the License.
2121
*/
2222

23-
actual fun getPlatformName(): String {
24-
return "Desktop"
25-
}
23+
actual fun getPlatformName(): String = "Desktop"
2624

2725
actual var databaseHelper = DatabaseHelper()
2826

common/src/commonMain/kotlin/com/linuxcommandlibrary/shared/App.kt

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,17 @@ sealed class CommandElement {
2929
/**
3030
* Search in name and description and return sorted by priority
3131
*/
32-
fun List<Command>.search(phrase: String): List<Command> {
33-
return this.filter { it.name.contains(phrase, true) || it.description.contains(phrase, true) }
34-
.sortedBy {
35-
val name = it.name.lowercase()
36-
val lowercasePhrase = phrase.lowercase()
37-
when {
38-
!name.contains(lowercasePhrase) -> 30
39-
name == lowercasePhrase -> 0
40-
name.startsWith(lowercasePhrase) -> 10
41-
else -> 20
42-
}
32+
fun List<Command>.search(phrase: String): List<Command> = this.filter { it.name.contains(phrase, true) || it.description.contains(phrase, true) }
33+
.sortedBy {
34+
val name = it.name.lowercase()
35+
val lowercasePhrase = phrase.lowercase()
36+
when {
37+
!name.contains(lowercasePhrase) -> 30
38+
name == lowercasePhrase -> 0
39+
name.startsWith(lowercasePhrase) -> 10
40+
else -> 20
4341
}
44-
}
42+
}
4543

4644
/**
4745
* Return a list of sealed Elements for visual representation
@@ -112,19 +110,15 @@ val onlyCharactersRegex = "[^a-z]".toRegex()
112110
/**
113111
* Only allow characters in html file names to guarantee matching on the website and app deep linking
114112
*/
115-
fun BasicCategory.getHtmlFileName(): String {
116-
return this.title.lowercase(Locale.US).replace(onlyCharactersRegex, "")
117-
}
113+
fun BasicCategory.getHtmlFileName(): String = this.title.lowercase(Locale.US).replace(onlyCharactersRegex, "")
118114

119115
/**
120116
* Show TLDR and SYNOPSIS always on the top and SEE ALSO and AUTHOR on the bottom. Everything else in between
121117
*/
122-
fun CommandSection.getSortPriority(): Int {
123-
return when (this.title) {
124-
"TLDR" -> 0
125-
"SYNOPSIS" -> 10
126-
"SEE ALSO" -> 90
127-
"AUTHOR" -> 100
128-
else -> 50
129-
}
118+
fun CommandSection.getSortPriority(): Int = when (this.title) {
119+
"TLDR" -> 0
120+
"SYNOPSIS" -> 10
121+
"SEE ALSO" -> 90
122+
"AUTHOR" -> 100
123+
else -> 50
130124
}

common/src/commonMain/kotlin/com/linuxcommandlibrary/shared/Platform.kt

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.linuxcommandlibrary.shared
22

3+
import app.cash.sqldelight.db.SqlDriver
34
import com.linuxcommandlibrary.CommandDatabase
4-
import com.squareup.sqldelight.db.SqlDriver
55
import databases.BasicCategory
66
import databases.BasicCommand
77
import databases.BasicGroup
@@ -39,35 +39,19 @@ class DatabaseHelper {
3939
commandQueries = CommandDatabase(sqlDriver).commandQueries
4040
}
4141

42-
fun getCommand(name: String): Command? {
43-
return commandQueries.selectCommandByName(name).executeAsOneOrNull()
44-
}
42+
fun getCommand(name: String): Command? = commandQueries.selectCommandByName(name).executeAsOneOrNull()
4543

46-
fun getCommands(): List<Command> {
47-
return commandQueries.selectCommands().executeAsList()
48-
}
44+
fun getCommands(): List<Command> = commandQueries.selectCommands().executeAsList()
4945

50-
fun getBasics(): List<BasicCategory> {
51-
return commandQueries.selectBasicCategories().executeAsList()
52-
}
46+
fun getBasics(): List<BasicCategory> = commandQueries.selectBasicCategories().executeAsList()
5347

54-
fun getBasicGroups(categoryId: Long): List<BasicGroup> {
55-
return commandQueries.selectBasicGroupByCategory(categoryId).executeAsList()
56-
}
48+
fun getBasicGroups(categoryId: Long): List<BasicGroup> = commandQueries.selectBasicGroupByCategory(categoryId).executeAsList()
5749

58-
fun getBasicCommands(groupId: Long): List<BasicCommand> {
59-
return commandQueries.selectBasicCommandByGroupId(groupId).executeAsList()
60-
}
50+
fun getBasicCommands(groupId: Long): List<BasicCommand> = commandQueries.selectBasicCommandByGroupId(groupId).executeAsList()
6151

62-
fun getSections(commandId: Long): List<CommandSection> {
63-
return commandQueries.selectCommandSectionsByCommandId(commandId).executeAsList()
64-
}
52+
fun getSections(commandId: Long): List<CommandSection> = commandQueries.selectCommandSectionsByCommandId(commandId).executeAsList()
6553

66-
fun getTips(): List<Tip> {
67-
return commandQueries.selectTips().executeAsList()
68-
}
54+
fun getTips(): List<Tip> = commandQueries.selectTips().executeAsList()
6955

70-
fun getTipSections(): List<TipSection> {
71-
return commandQueries.selectAllTipSections().executeAsList()
72-
}
56+
fun getTipSections(): List<TipSection> = commandQueries.selectAllTipSections().executeAsList()
7357
}

desktop/src/main/kotlin/com/linuxcommandlibrary/desktop/WebsiteBuilder.kt

Lines changed: 75 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,9 @@ class WebsiteBuilder {
825825
stream.close()
826826
}
827827

828-
private fun getSitemapUrlNode(urlPart: String): String {
829-
return "<url>" +
830-
"<loc>https://linuxcommandlibrary.com/$urlPart</loc>" +
831-
"</url>"
832-
}
828+
private fun getSitemapUrlNode(urlPart: String): String = "<url>" +
829+
"<loc>https://linuxcommandlibrary.com/$urlPart</loc>" +
830+
"</url>"
833831

834832
private fun HEAD.commonMeta() {
835833
meta(charset = "utf-8")
@@ -1071,88 +1069,82 @@ class WebsiteBuilder {
10711069
consumer,
10721070
).visit(block)
10731071

1074-
private fun BasicCategory.getIconResource(): String {
1075-
return when (title) {
1076-
"One-liners" -> "icon-hand_with_pen.svg"
1077-
"System information" -> "icon-system_task.svg"
1078-
"System control" -> "icon-settings.svg"
1079-
"Users & Groups" -> "icon-user.svg"
1080-
"Files & Folders" -> "icon-file.svg"
1081-
"Printing" -> "icon-print.svg"
1082-
"Network" -> "icon-network_card.svg"
1083-
"Search & Find" -> "icon-search.svg"
1084-
"GIT" -> "icon-git.svg"
1085-
"SSH" -> "icon-console.svg"
1086-
"Video & Audio" -> "icon-video_trimming.svg"
1087-
"Package manager" -> "icon-package.svg"
1088-
"Hacking tools" -> "icon-skull.svg"
1089-
"Terminal games" -> "icon-controller.svg"
1090-
"VIM" -> "icon-vim.svg"
1091-
"Emacs" -> "icon-emacs.svg"
1092-
"Nano" -> "icon-nano.svg"
1093-
"Pico" -> "icon-pico.svg"
1094-
"Crypto currencies" -> "icon-bitcoin.svg"
1095-
"Input" -> "icon-mouse.svg"
1096-
"JSON" -> "icon-json.svg"
1097-
"Fun" -> "icon-fun.svg"
1098-
else -> ""
1099-
}
1072+
private fun BasicCategory.getIconResource(): String = when (title) {
1073+
"One-liners" -> "icon-hand_with_pen.svg"
1074+
"System information" -> "icon-system_task.svg"
1075+
"System control" -> "icon-settings.svg"
1076+
"Users & Groups" -> "icon-user.svg"
1077+
"Files & Folders" -> "icon-file.svg"
1078+
"Printing" -> "icon-print.svg"
1079+
"Network" -> "icon-network_card.svg"
1080+
"Search & Find" -> "icon-search.svg"
1081+
"GIT" -> "icon-git.svg"
1082+
"SSH" -> "icon-console.svg"
1083+
"Video & Audio" -> "icon-video_trimming.svg"
1084+
"Package manager" -> "icon-package.svg"
1085+
"Hacking tools" -> "icon-skull.svg"
1086+
"Terminal games" -> "icon-controller.svg"
1087+
"VIM" -> "icon-vim.svg"
1088+
"Emacs" -> "icon-emacs.svg"
1089+
"Nano" -> "icon-nano.svg"
1090+
"Pico" -> "icon-pico.svg"
1091+
"Crypto currencies" -> "icon-bitcoin.svg"
1092+
"Input" -> "icon-mouse.svg"
1093+
"JSON" -> "icon-json.svg"
1094+
"Fun" -> "icon-fun.svg"
1095+
else -> ""
11001096
}
11011097

1102-
private fun BasicCategory.getDescription(): String {
1103-
return when (title) {
1104-
"One-liners" -> "Useful linux command line one liners"
1105-
"System information" -> "System and battery/cpu/memory/disk usage info on Linux "
1106-
"System control" -> "Lock, unlock, start/stop bluetooth/wifi, shutdown, reboot system"
1107-
"Users & Groups" -> "Create, remove, modify and list Linux groups and users"
1108-
"Files & Folders" -> "Create, delete, list, show and change Linux files and folders"
1109-
"Printing" -> "Print, view, start and cancel printing jobs on Linux"
1110-
"Network" -> "Configure, list, trace, sockets, wifi networks on Linux"
1111-
"Search & Find" -> "Search and find files by phrase, date and size on Linux"
1112-
"GIT" -> "Commit, push, create, delete and undo with git on Linux"
1113-
"SSH" -> "Connect, forward, push and pull files via SSH"
1114-
"Video & Audio" -> "Convert, volume, play, screenshot, webcam on Linux"
1115-
"Package manager" -> "Install, update, upgrade, remove packages on Linux"
1116-
"Hacking tools" -> "Hacking, forensics and exploitation tools for Linux"
1117-
"Terminal games" -> "Terminal games on Linux"
1118-
"VIM" -> "Working with vim on the Linux command line"
1119-
"Emacs" -> "Working with emacs on the Linux command line"
1120-
"Nano" -> "Working with nano on the Linux command line"
1121-
"Pico" -> "Working with pico on the Linux command line"
1122-
"Crypto currencies" -> "Miners, wallets and trading bots for Linux"
1123-
"Input" -> "Type keys and move mouse via the Linux command line"
1124-
"JSON" -> "Print, select, modify, delete and create json files on cmd"
1125-
"Fun" -> "Fun on the linux command line"
1126-
else -> ""
1127-
}
1098+
private fun BasicCategory.getDescription(): String = when (title) {
1099+
"One-liners" -> "Useful linux command line one liners"
1100+
"System information" -> "System and battery/cpu/memory/disk usage info on Linux "
1101+
"System control" -> "Lock, unlock, start/stop bluetooth/wifi, shutdown, reboot system"
1102+
"Users & Groups" -> "Create, remove, modify and list Linux groups and users"
1103+
"Files & Folders" -> "Create, delete, list, show and change Linux files and folders"
1104+
"Printing" -> "Print, view, start and cancel printing jobs on Linux"
1105+
"Network" -> "Configure, list, trace, sockets, wifi networks on Linux"
1106+
"Search & Find" -> "Search and find files by phrase, date and size on Linux"
1107+
"GIT" -> "Commit, push, create, delete and undo with git on Linux"
1108+
"SSH" -> "Connect, forward, push and pull files via SSH"
1109+
"Video & Audio" -> "Convert, volume, play, screenshot, webcam on Linux"
1110+
"Package manager" -> "Install, update, upgrade, remove packages on Linux"
1111+
"Hacking tools" -> "Hacking, forensics and exploitation tools for Linux"
1112+
"Terminal games" -> "Terminal games on Linux"
1113+
"VIM" -> "Working with vim on the Linux command line"
1114+
"Emacs" -> "Working with emacs on the Linux command line"
1115+
"Nano" -> "Working with nano on the Linux command line"
1116+
"Pico" -> "Working with pico on the Linux command line"
1117+
"Crypto currencies" -> "Miners, wallets and trading bots for Linux"
1118+
"Input" -> "Type keys and move mouse via the Linux command line"
1119+
"JSON" -> "Print, select, modify, delete and create json files on cmd"
1120+
"Fun" -> "Fun on the linux command line"
1121+
else -> ""
11281122
}
11291123

1130-
private fun getKeywordsForBasic(category: BasicCategory): String {
1131-
return when (category.title) {
1132-
"One-liners" -> "linux,list,useful,oneliners,commands,cmd"
1133-
"Input" -> "linux,move,click,mouse,type,text,xdotool,ydotool,read,copy,clipboard"
1134-
"System information" -> "linux,system,info,disk,bluetooth,cpu,memory,battery"
1135-
"System control" -> "linux,control,lock,unlock,reboot,shutdown,start,stop,wifi,bluetooth"
1136-
"Users & Groups" -> "linux,create,delete,user,group,list,info"
1137-
"Files & Folders" -> "linux,create,edit,delete,file,folder,permission,list"
1138-
"Printing" -> "linux,print,file,cancel,job,status,queue"
1139-
"JSON" -> "linux,json,pretty,print,select,put,delete,create"
1140-
"Network" -> "linux,network,wifi,password,ip,interfaces,sockets"
1141-
"Search & Find" -> "linux,find,search,pattern,files,path,phrase"
1142-
"GIT" -> "linux,create,clone,repository,tag,checkout,delete,commit"
1143-
"SSH" -> "linux,connect,ssh,push,pull,forwarding"
1144-
"Video & Audio" -> "linux,screenshot,webcam,sounds,video,convert,image"
1145-
"Package manager" -> "linux,install,file,repository,find,package,upgrade"
1146-
"Hacking tools" -> "linux,password,forensics,sniffing,spoofing,exploit,vulnerability"
1147-
"Crypto currencies" -> "linux,minters,wallets,coin,trading,bots"
1148-
"VIM Texteditor" -> "linux,insert,search,edit,replace,navigation"
1149-
"Emacs Texteditor" -> "linux,emacs,usage,buffers,navigation"
1150-
"Nano Texteditor" -> "linux,nano,info,navigation,edit,input,output"
1151-
"Pico Texteditor" -> "linux,pico,navigation,usage,input,output"
1152-
"Micro Texteditor" -> "linux,pico,navigation,usage,input,output"
1153-
"Terminal games" -> "linux,terminal,games,list,rogue"
1154-
else -> throw Exception("${category.title} not found")
1155-
}
1124+
private fun getKeywordsForBasic(category: BasicCategory): String = when (category.title) {
1125+
"One-liners" -> "linux,list,useful,oneliners,commands,cmd"
1126+
"Input" -> "linux,move,click,mouse,type,text,xdotool,ydotool,read,copy,clipboard"
1127+
"System information" -> "linux,system,info,disk,bluetooth,cpu,memory,battery"
1128+
"System control" -> "linux,control,lock,unlock,reboot,shutdown,start,stop,wifi,bluetooth"
1129+
"Users & Groups" -> "linux,create,delete,user,group,list,info"
1130+
"Files & Folders" -> "linux,create,edit,delete,file,folder,permission,list"
1131+
"Printing" -> "linux,print,file,cancel,job,status,queue"
1132+
"JSON" -> "linux,json,pretty,print,select,put,delete,create"
1133+
"Network" -> "linux,network,wifi,password,ip,interfaces,sockets"
1134+
"Search & Find" -> "linux,find,search,pattern,files,path,phrase"
1135+
"GIT" -> "linux,create,clone,repository,tag,checkout,delete,commit"
1136+
"SSH" -> "linux,connect,ssh,push,pull,forwarding"
1137+
"Video & Audio" -> "linux,screenshot,webcam,sounds,video,convert,image"
1138+
"Package manager" -> "linux,install,file,repository,find,package,upgrade"
1139+
"Hacking tools" -> "linux,password,forensics,sniffing,spoofing,exploit,vulnerability"
1140+
"Crypto currencies" -> "linux,minters,wallets,coin,trading,bots"
1141+
"VIM Texteditor" -> "linux,insert,search,edit,replace,navigation"
1142+
"Emacs Texteditor" -> "linux,emacs,usage,buffers,navigation"
1143+
"Nano Texteditor" -> "linux,nano,info,navigation,edit,input,output"
1144+
"Pico Texteditor" -> "linux,pico,navigation,usage,input,output"
1145+
"Micro Texteditor" -> "linux,pico,navigation,usage,input,output"
1146+
"Terminal games" -> "linux,terminal,games,list,rogue"
1147+
else -> throw Exception("${category.title} not found")
11561148
}
11571149

11581150
fun String.addAnchorAndCodeStyle(fileName: String): String {

0 commit comments

Comments
 (0)