Skip to content

Commit

Permalink
FileConventions: improvements to Library.fs
Browse files Browse the repository at this point in the history
An assert error message has been added for *.fsx files &
renaming the func.
  • Loading branch information
Mersho committed Sep 7, 2023
1 parent 541a03b commit 59590da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions scripts/dotnetFileConventions.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ if args.Length > 1 then
let rootDir = DirectoryInfo args.[0]

// DefiningEmptyStringsWithDoubleQuotes
let allSourceFiles = ReturnAllProjectSourceFile rootDir [ "*.cs"; "*.fs" ] true
let allSourceFiles = ReturnAllProjectSourceFiles rootDir [ "*.cs"; "*.fs" ] true
printfn "%A" (String.Join("\n", allSourceFiles))

let allProjFiles =
ReturnAllProjectSourceFile rootDir [ "*.csproj"; "*.fsproj" ] true
ReturnAllProjectSourceFiles rootDir [ "*.csproj"; "*.fsproj" ] true

for sourceFile in allSourceFiles do
let isStringEmpty = DefiningEmptyStringsWithDoubleQuotes sourceFile
Expand Down
13 changes: 5 additions & 8 deletions src/FileConventions/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ open Fsdk
let ymlAssertionError = "Bug: file should be a .yml file"
let projAssertionError = "Bug: file should be a proj file"
let sourceFileAssertionError = "Bug: file was not a F#/C# source file"
let fsxAssertionError = "Bug: file was not a F# script source file"

let HasCorrectShebang(fileInfo: FileInfo) =
let fileText = File.ReadLines fileInfo.FullName
Expand Down Expand Up @@ -88,9 +89,7 @@ let DetectAsteriskInPackageReferenceItems(fileInfo: FileInfo) =
asteriskInPackageReference.IsMatch fileText

let DetectMissingVersionsInNugetPackageReferences(fileInfo: FileInfo) =
Misc.BetterAssert
(fileInfo.FullName.EndsWith ".fsx")
sourceFileAssertionError
Misc.BetterAssert (fileInfo.FullName.EndsWith ".fsx") fsxAssertionError

let fileLines = File.ReadLines fileInfo.FullName

Expand Down Expand Up @@ -320,9 +319,7 @@ let DetectInconsistentVersionsInNugetRefsInFSharpScripts
=
fileInfos
|> Seq.iter(fun fileInfo ->
Misc.BetterAssert
(fileInfo.FullName.EndsWith ".fsx")
sourceFileAssertionError
Misc.BetterAssert (fileInfo.FullName.EndsWith ".fsx") fsxAssertionError
)

DetectInconsistentVersions
Expand Down Expand Up @@ -491,7 +488,7 @@ let ContainsConsoleMethods(fileInfo: FileInfo) =
checkLine fileLines


let ReturnAllProjectSourceFile
let ReturnAllProjectSourceFiles
(parentDir: DirectoryInfo)
(patterns: List<string>)
(shouldFilter: bool)
Expand Down Expand Up @@ -521,7 +518,7 @@ let NotFollowingConsoleAppConvention (fileInfo: FileInfo) (shouldFilter: bool) =

if not(fileText.Contains "<OutputType>Exe</OutputType>") then
let sourceFiles =
ReturnAllProjectSourceFile
ReturnAllProjectSourceFiles
(DirectoryInfo parentDir)
[ "*.cs"; "*.fs" ]
shouldFilter
Expand Down

0 comments on commit 59590da

Please sign in to comment.