deepsourcestatus / test-repository

Missing package declaration for file SC-W1045
Bug risk
Minor
1 occurrence in this check
Source file is missing package statement at the top
 1import scala.io.Source 2import scala.collection.mutable 3import scala.collection.immutable 4 5class C { 6  override def finalize(): Unit = println("Finalize") 7} 8 9object Utils {10  def count(arr: Array[Int], criteria: Int => Boolean): Int                                = arr.filter(criteria).size11  def exists(arr: Array[Int], criteria: Int => Boolean): Boolean                           = arr.find(criteria).isDefined12  def filterBy(arr: Array[Int], criteria: Int => Boolean): Array[Int]                      = arr.filter(criteria)13  def filterBy(arr: Array[Int], first: Int => Boolean, `then`: Int => Boolean): Array[Int] =14    arr.filter(first).filter(`then`)1516  def pickBy(arr: Array[Int], criteria: Int => Boolean): Unit = {17    for (i <- 0 to arr.length - 1) {18      if (criteria(arr(i))) {19        println(s"Picked at $i")20      }21    }22  }2324  def pickFirst1(arr: Array[Int], criteria: Int => Boolean): Int           = arr.filter(criteria).head25  def pickFirst2(arr: Array[Int], criteria: Int => Boolean): Option[Int]   =26    arr.filter(criteria).headOption27  def pickInAnOrder(arr: Array[Int], criteria: Int => Boolean): Array[Int] =28    arr.sortWith(_ < _).filter(criteria)2930  def readFile(path: String): String = Source.fromFile(path).mkString3132  @Deprecated()33  def cmpArray1(arr1: Array[Int], arr2: Array[Int]): Boolean = arr1 == arr234  def stringifyArray(arr: Array[Int]): String                = arr.toString35}3637object Main extends App {38  var filtered = Utils.filterBy(Range.inclusive(1, 100).toArray, criteria = x => x % 2 == 0)39  if (!filtered.isEmpty) {40    println(s"Found elements satisfying our criteria")41  }4243  var lang1 = "Scala"44  var lang2 = "scala"45  if (lang1.equals(lang2)) {46    var substr = lang2.substring(0, lang2.length - 1)47  }4849  lang1.foreach { c =>50    c match {51      case 'a' => println('a')52      case 'b' => println('b')53      case 'a' => println('a')54    }55  }5657  println(lang1.indexOf("a"))58  var sb = new mutable.StringBuilder('a')59}6061object BubbleSort {62  def bubbleSort(array: Array[Int]): Array[Int] = {63    breakable {64      for (_ <- array.indices) {65        var swap = false6667        for (j <- 0 to array.length - 2) {68          if (array(j) > array(j + 1)) {69            val temp = array(j)70            array(j) = array(j + 1)71            array(j + 1) = temp72            swap = true73          }74        }75        if (!swap) {76          break()77        }78      }79    }80    array81  }8283}