-
Notifications
You must be signed in to change notification settings - Fork 10
Easy dotnet conventions to verify #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easy dotnet conventions to verify #139
Conversation
Add tests for DefiningEmptyStringsWithDoubleQuotes function.
Implement DefiningEmptyStringsWithDoubleQuotes function.
Add tests for ProjFilesNamingConvention function.
Implement ProjFilesNamingConvention function.
Add tests for NotFollowingNamespaceConvention function.
Implement NotFollowingNamespaceConvention function.
Add more tests for NotFollowingNamespaceConvention fn.
Fix NotFollowingNamespaceConvention function.
756f364
to
275d6d1
Compare
Add one more test for NotFollowingNamespaceConvention function.
Function DoesNamespaceInclude doesn't working on *.cs namespace.
21f3749
to
b0acb0c
Compare
[<Test>] | ||
let DefiningEmptyStringsWithDoubleQuotes1() = | ||
let fileInfo = | ||
(FileInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra parens
[<Test>] | ||
let DefiningEmptyStringsWithDoubleQuotes2() = | ||
let fileInfo = | ||
(FileInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra parens
[<Test>] | ||
let ProjFilesNamingConvention2() = | ||
let fileInfo = | ||
(FileInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra paren.
) | ||
)) | ||
|
||
Assert.That(ProjFilesNamingConvention fileInfo, Is.EqualTo true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it easier to use Assert.True?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, Assert.That is fine
[<Test>] | ||
let ProjFilesNamingConvention1() = | ||
let fileInfo = | ||
(FileInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra paren
) | ||
)) | ||
|
||
Assert.That(ProjFilesNamingConvention fileInfo, Is.EqualTo false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert.False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope
src/FileConventions/Library.fs
Outdated
@@ -396,5 +396,16 @@ let DefiningEmptyStringsWithDoubleQuotes(fileInfo: FileInfo) = | |||
fileText.Contains "\"\"" | |||
|
|||
let ProjFilesNamingConvention(fileInfo: FileInfo) = | |||
printfn "%s" fileInfo.FullName | |||
false | |||
let regex = new Regex("(.*)\..*proj$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for new keyword
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also extra paren.
src/FileConventions/Library.fs
Outdated
printfn "%s" fileInfo.FullName | ||
false | ||
let regex = new Regex("(.*)\..*proj$") | ||
assert (regex.IsMatch fileInfo.FullName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about this but I think paren is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is needed; because assert
doesn't receive 2 currified arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert is for debug mode only, are we sure it should be used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is needed; because
assert
doesn't receive 2 currified arguments
Not sure because it compiles without them 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aarani you're right, they should use Fsdk's Misc.BetterAssert
) | ||
)) | ||
|
||
Assert.That(NotFollowingNamespaceConvention fileInfo, Is.EqualTo true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert.True?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope
[<Test>] | ||
let NamespaceConvention1() = | ||
let fileInfo = | ||
(FileInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra paren
[<Test>] | ||
let NamespaceConvention2() = | ||
let fileInfo = | ||
(FileInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra paren
) | ||
)) | ||
|
||
Assert.That(NotFollowingNamespaceConvention fileInfo, Is.EqualTo false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert.False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope
src/FileConventions/Library.fs
Outdated
@@ -411,5 +411,31 @@ let ProjFilesNamingConvention(fileInfo: FileInfo) = | |||
fileName <> parentDirectoryName | |||
|
|||
let NotFollowingNamespaceConvention(fileInfo: FileInfo) = | |||
printfn "%s" fileInfo.FullName | |||
false | |||
assert (fileInfo.FullName.EndsWith(".fs")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra paren
@@ -13,6 +13,7 @@ | |||
<ItemGroup> | |||
<PackageReference Include="Mono.Posix" Version="7.1.0-final.1.21458.1" /> | |||
<PackageReference Include="Mono.Unix" Version="7.1.0-final.1.21458.1" /> | |||
<PackageReference Include="Fsdk" Version="0.6.0--date20230821-0702.git-5488853" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mersho same here
src/FileConventions/Library.fs
Outdated
|
||
let ymlAssertionError = "Bug: file should be a .yml file" | ||
let projAssertionError = "Bug: file should be a proj file" | ||
let fsxAssertionError = "Bug: file was not a F#/C# source file" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mersho if it's an error about F# or C# files, then why do you call it "Fsx Assertion Error"?
1342e1d
to
6e74482
Compare
Using RemoveEmptyEntries for split & removing extra parans & Regex does not require a new keyword & string formatting has been corrected.
Add tests for NotFollowingConsoleAppConvention() function.
Ensure that projects that aren't console applications don't have source files with console methods. Co-authored-by: Parham <parhaamsaremi@gmail.com>
Add tests for NotFollowingConsoleAppConvention function and we fix ConsoleAppConvention2 test so that project name does not contradict new tests.
Fix NotFollowingConsoleAppConvention() function.
Add tests for async project, Async.RunSynchronously only allowed in console applications.
Fix NotFollowingConsoleAppConvention() function.
83803e8
to
e124a91
Compare
Add test for NotFollowingNamespaceConvention fn.
A .fs/fsx file might not have a namespace sometimes.
`Contains()` method catches a lot of false-positives and not suitable for this situation so we used regex. Co-authored-by: Parham <parhaamsaremi@gmail.com>
Fix `DefiningEmptyStringsWithDoubleQuotes()` function by using regex insted of `Contains()`. Co-authored-by: Parham <parhaamsaremi@gmail.com>
10b55f8
to
5358b96
Compare
Finding printf and console methods in files & removed printf methods used for debugging purposes & added file filter to ReturnAllProjectSourceFile.
The new dotnetFileConvention.fsx script detects empty strings, wrong namespace usage, and incorrect printf methods on non-console applications.
8fb77c7
to
18b828e
Compare
@Mersho CI is still red |
I don't have access to re-run CI, do you think I should re-push?
|
Ask Zahra to give you access. The telegram channel is meant for this king of things.
Next time you face a problem like this, just repush while you wait for someone to give you perms; you shouldn't need to depend on me for this kind of small things :) |
BTW, I say "Next time" because I'm going to re-run that CI now, but this shouldn't mean that you don't need to ask for Zahra's perms anymore. |
@Mersho the next CI issue might be a permissions problem because Zahra changed her username, I think. Let's workaround this by just opening a new PR from your account. |
The pull request has been superseded by a newer one |
Working on #122.