Repository: scala-steward-org/scala-steward
Pull request #1896 (2021-01-19 19:39:24)

Test FileAlg.isRegularFile

codecov[bot]: # [Codecov](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896?src=pr&el=h1) Report
> Merging [#1896](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896?src=pr&el=desc) (bee07b6) into [master](https://codecov.io/gh/scala-steward-org/scala-steward/commit/9c51273ea784f203b5b9f8bfa031efe84e3dc40f?el=desc) (9c51273) will **increase** coverage by `1.47%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896/graphs/tree.svg?width=650&height=150&src=pr&token=udzMsc1Dne)](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1896      +/-   ##
==========================================
+ Coverage   76.80%   78.28%   +1.47%     
==========================================
  Files         129      128       -1     
  Lines        2212     2210       -2     
  Branches       57       61       +4     
==========================================
+ Hits         1699     1730      +31     
+ Misses        513      480      -33     
```


| [Impacted Files](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...g/scalasteward/core/application/SelfCheckAlg.scala](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896/diff?src=pr&el=tree#diff-bW9kdWxlcy9jb3JlL3NyYy9tYWluL3NjYWxhL29yZy9zY2FsYXN0ZXdhcmQvY29yZS9hcHBsaWNhdGlvbi9TZWxmQ2hlY2tBbGcuc2NhbGE=) | `100.00% <100.00%> (+100.00%)` | :arrow_up: |
| [...ain/scala/org/scalasteward/core/edit/EditAlg.scala](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896/diff?src=pr&el=tree#diff-bW9kdWxlcy9jb3JlL3NyYy9tYWluL3NjYWxhL29yZy9zY2FsYXN0ZXdhcmQvY29yZS9lZGl0L0VkaXRBbGcuc2NhbGE=) | `57.14% <0.00%> (-2.12%)` | :arrow_down: |
| [...la-2.12/org/scalasteward/mill/plugin/package.scala](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896/diff?src=pr&el=tree#diff-bW9kdWxlcy9taWxsLXBsdWdpbi9zcmMvbWFpbi9zY2FsYS0yLjEyL29yZy9zY2FsYXN0ZXdhcmQvbWlsbC9wbHVnaW4vcGFja2FnZS5zY2FsYQ==) | | |
| [.../main/scala/org/scalasteward/core/io/FileAlg.scala](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896/diff?src=pr&el=tree#diff-bW9kdWxlcy9jb3JlL3NyYy9tYWluL3NjYWxhL29yZy9zY2FsYXN0ZXdhcmQvY29yZS9pby9GaWxlQWxnLnNjYWxh) | `93.75% <0.00%> (+6.25%)` | :arrow_up: |
| [...a/org/scalasteward/core/scalafmt/ScalafmtAlg.scala](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896/diff?src=pr&el=tree#diff-bW9kdWxlcy9jb3JlL3NyYy9tYWluL3NjYWxhL29yZy9zY2FsYXN0ZXdhcmQvY29yZS9zY2FsYWZtdC9TY2FsYWZtdEFsZy5zY2FsYQ==) | `100.00% <0.00%> (+33.33%)` | :arrow_up: |
| [...org/scalasteward/core/application/StewardAlg.scala](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896/diff?src=pr&el=tree#diff-bW9kdWxlcy9jb3JlL3NyYy9tYWluL3NjYWxhL29yZy9zY2FsYXN0ZXdhcmQvY29yZS9hcHBsaWNhdGlvbi9TdGV3YXJkQWxnLnNjYWxh) | `42.85% <0.00%> (+42.85%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896?src=pr&el=footer). Last update [9c51273...bee07b6](https://codecov.io/gh/scala-steward-org/scala-steward/pull/1896?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/build.sbt b/build.sbt
index 5516d497..b4741609 100644
--- a/build.sbt
+++ b/build.sbt
@@ -212,7 +212,7 @@ lazy val commonSettings = Def.settings(
 
 lazy val compileSettings = Def.settings(
   scalaVersion := Scala213,
-  doctestTestFramework := DoctestTestFramework.ScalaCheck,
+  doctestTestFramework := DoctestTestFramework.Munit,
   wartremoverErrors ++= Seq(Wart.TraversableOps),
   Compile / compile / wartremoverErrors ++= Seq(Wart.Equals)
 )
diff --git a/modules/core/src/main/scala/org/scalasteward/core/application/SelfCheckAlg.scala b/modules/core/src/main/scala/org/scalasteward/core/application/SelfCheckAlg.scala
index 12efab1a..8169dc6a 100644
--- a/modules/core/src/main/scala/org/scalasteward/core/application/SelfCheckAlg.scala
+++ b/modules/core/src/main/scala/org/scalasteward/core/application/SelfCheckAlg.scala
@@ -21,8 +21,9 @@ import cats.syntax.all._
 import io.chrisdavenport.log4cats.Logger
 import org.http4s.Uri
 import org.scalasteward.core.git.GitAlg
-import org.scalasteward.core.scalafmt.ScalafmtAlg
+import org.scalasteward.core.scalafmt.{scalafmtBinary, ScalafmtAlg}
 import org.scalasteward.core.util.UrlChecker
+import org.scalasteward.core.util.logger.LoggerOps
 
 final class SelfCheckAlg[F[_]](implicit
     gitAlg: GitAlg[F],
@@ -40,23 +41,18 @@ final class SelfCheckAlg[F[_]](implicit
     } yield ()
 
   private def checkGitBinary: F[Unit] =
-    gitAlg.version.attempt.flatMap {
-      case Right(output) => logger.info(s"Using $output")
-      case Left(throwable) =>
-        logger.warn(throwable)(
-          "Failed to execute git -- make sure it is on the PATH; following the detailed exception:"
-        )
+    logger.attemptLogWarn_(execFailedMessage("git")) {
+      gitAlg.version.flatMap(output => logger.info(s"Using $output"))
     }
 
   private def checkScalafmtBinary: F[Unit] =
-    scalafmtAlg.version.attempt.flatMap {
-      case Right(output) => logger.info(s"Using $output")
-      case Left(throwable) =>
-        logger.warn(throwable)(
-          "Failed to execute scalafmt  -- make sure it is on the PATH; following the detailed exception:"
-        )
+    logger.attemptLogWarn_(execFailedMessage(scalafmtBinary)) {
+      scalafmtAlg.version.flatMap(output => logger.info(s"Using $output"))
     }
 
+  private def execFailedMessage(binary: String): String =
+    s"Failed to execute $binary  -- make sure it is on the PATH; following the detailed exception:"
+
   private def checkUrlChecker: F[Unit] =
     for {
       url <- F.fromEither(Uri.fromString("https://github.com"))


Test patch:
diff --git a/modules/core/src/test/scala/org/scalasteward/core/io/FileAlgTest.scala b/modules/core/src/test/scala/org/scalasteward/core/io/FileAlgTest.scala
index e139d412..6e64e6c3 100644
--- a/modules/core/src/test/scala/org/scalasteward/core/io/FileAlgTest.scala
+++ b/modules/core/src/test/scala/org/scalasteward/core/io/FileAlgTest.scala
@@ -58,11 +58,8 @@ class FileAlgTest extends FunSuite {
       edited <- fileAlg.editFile(home / "does-not-exists.txt", Some.apply)
     } yield edited).run(MockState.empty).unsafeRunSync()
 
-    val expected = MockState.empty.copy(
-      commands = Vector(
-        List("read", "/tmp/steward/does-not-exists.txt")
-      )
-    )
+    val expected =
+      MockState.empty.copy(commands = Vector(List("read", "/tmp/steward/does-not-exists.txt")))
     assertEquals(state, expected)
     assert(!edited)
   }
@@ -113,6 +110,18 @@ class FileAlgTest extends FunSuite {
     } yield read
     assertEquals(p.unsafeRunSync(), content)
   }
+
+  test("isRegularFile") {
+    val dir = File.temp / "steward" / "regular"
+    val file = dir / "file.txt"
+    val p = for {
+      _ <- ioFileAlg.deleteForce(dir)
+      r1 <- ioFileAlg.isRegularFile(file)
+      _ <- ioFileAlg.writeFileData(dir, FileData("file.txt", "content"))
+      r2 <- ioFileAlg.isRegularFile(file)
+    } yield (r1, r2)
+    assertEquals(p.unsafeRunSync(), (false, true))
+  }
 }
 
 object FileAlgTest {