Skip to content

Commit 57db630

Browse files
committed
Fix scalafmt
1 parent b8a4b82 commit 57db630

9 files changed

+27
-29
lines changed

.github/workflows/lint-checker.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ jobs:
1010
uses: actions/checkout@v3
1111
with:
1212
fetch-depth: 0
13-
#- name: Check Python
14-
# uses: wemake-services/wemake-python-styleguide@0.17.0
15-
- name: Lint Code Base
13+
- name: Check Code
1614
uses: github/super-linter@v5
1715
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1817
VALIDATE_SCALAFMT: true

src/scala/BubbleSort.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
21
def bubble_sort(data: List[Int]): List[Int] = {
32
var sortedData: List[Int] = data
4-
var swapped: Boolean = true
3+
var swapped: Boolean = true
4+
55
while (swapped == true) {
66
swapped = false
77
for (i <- 0 to sortedData.length - 2) {
88
if (sortedData(i) > sortedData(i+1)) {
9-
sortedData = sortedData.updated(i, sortedData(i+1)).updated(i+1, sortedData(i))
9+
sortedData =
10+
sortedData.updated(i, sortedData(i+1)).updated(i+1, sortedData(i))
1011
swapped = true
1112
}
1213
}

src/scala/CalculatePi.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
21
def calculatePi(n: Int): Double = {
32
(0 until n).foldLeft(0.0)((pi, index) => {
4-
val operation: Double = if (index % 2 == 0) 1.0 else -1.0
3+
val operation: Double = if (index % 2 == 0) 1.0 else -1.0
54
val denominator: Double = 1.0 + (index * 2.0)
65
pi + (operation * (4.0 / denominator))
76
})

src/scala/Fatorial.scala

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
21
def fatorial(n: Long): Long = (1L to n).product
32

43
object Main extends App {
54
val data: Map[Long, Long] = Map(
6-
0L -> 1L,
7-
1L -> 1L,
8-
5L -> 120L,
5+
0L -> 1L,
6+
1L -> 1L,
7+
5L -> 120L,
98
20L -> 2432902008176640000L
109
)
11-
data.foreach{ (key, value) =>
10+
data.foreach { (key, value) =>
1211
val result: Long = fatorial(key)
1312
assert(result == value)
1413
println(s"Fatorial($key): $result")

src/scala/FatorialRecursiva.scala

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
21
def fatorial(n: Long): Long = {
32
n match {
43
case 0L | 1L => 1L
5-
case _ => n * fatorial(n - 1L)
4+
case _ => n * fatorial(n - 1L)
65
}
76
}
87

98
object Main extends App {
109
val data: Map[Long, Long] = Map(
11-
0L -> 1L,
12-
1L -> 1L,
13-
5L -> 120L,
10+
0L -> 1L,
11+
1L -> 1L,
12+
5L -> 120L,
1413
20L -> 2432902008176640000L
1514
)
16-
data.foreach{ (key, value) =>
15+
data.foreach { (key, value) =>
1716
val result: Long = fatorial(key)
1817
assert(result == value)
1918
println(s"Fatorial($key): $result")

src/scala/MaxRecursivo.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
def recursiveMax(data: List[Int], max: Int, index: Int): Int = {
32
var maximum = max
43
if (data(index) > max) {
@@ -14,6 +13,6 @@ def recursiveMax(data: List[Int]): Int = recursiveMax(data, data(0), 0)
1413

1514
object Main extends App {
1615
val data: List[Int] = List(1, 5, 2, 7, 3, 9, 4, 6)
17-
val max = recursiveMax(data)
16+
val max: Int = recursiveMax(data)
1817
println(s"$data\nMax: $max")
1918
}

src/scala/MinMaxIterativo.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
def minMax(data: List[Int]): (Int, Int) = {
32
var min: Int = data(0)
43
var max: Int = data(0)
@@ -14,7 +13,7 @@ def minMax(data: List[Int]): (Int, Int) = {
1413
}
1514

1615
object Main extends App {
17-
val data: List[Int] = List(4, 6, 2, 9, 3, 8, 1, 7, 5)
18-
val (min, max) = minMax(data)
16+
val data: List[Int] = List(4, 6, 2, 9, 3, 8, 1, 7, 5)
17+
val (min, max): (Int, Int) = minMax(data)
1918
println(s"$data\nMin: $min\nMax: $max")
2019
}

src/scala/MinMaxRecursivo.scala

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
2-
def minMax(data: List[Int], minimum: Int, maximum: Int, index: Int): (Int, Int) = {
1+
def minMax(
2+
data: List[Int],
3+
minimum: Int,
4+
maximum: Int,
5+
index: Int
6+
): (Int, Int) = {
37
var min: Int = minimum
48
var max: Int = maximum
59

@@ -20,7 +24,7 @@ def minMax(data: List[Int], minimum: Int, maximum: Int, index: Int): (Int, Int)
2024
def minMax(data: List[Int]): (Int, Int) = minMax(data, data(0), data(0), 0)
2125

2226
object Main extends App {
23-
val data: List[Int] = List(4, 6, 2, 9, 3, 8, 1, 7, 5)
24-
val (min, max) = minMax(data)
27+
val data: List[Int] = List(4, 6, 2, 9, 3, 8, 1, 7, 5)
28+
val (min, max): (Int, Int) = minMax(data)
2529
println(s"$data\nMin: $min\nMax: $max")
2630
}

src/scala/TorreDeHanoi.scala

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
def hanoi(pin0: Int, pin2: Int, pin1: Int, disks: Int): Unit = {
32
if (disks == 1) {
43
println(s"Move de $pin0 para $pin2")

0 commit comments

Comments
 (0)