Skip to content
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

tehraninasab
Copy link
Contributor

Working on #122.

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.
@Mersho Mersho force-pushed the verifyDotnetConventions-squashed branch 2 times, most recently from 756f364 to 275d6d1 Compare August 17, 2023 13:43
Add one more test for NotFollowingNamespaceConvention function.
Function DoesNamespaceInclude doesn't working on *.cs namespace.
@Mersho Mersho force-pushed the verifyDotnetConventions-squashed branch 3 times, most recently from 21f3749 to b0acb0c Compare August 17, 2023 14:01
[<Test>]
let DefiningEmptyStringsWithDoubleQuotes1() =
let fileInfo =
(FileInfo(
Copy link
Contributor

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(
Copy link
Contributor

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(
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Member

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(
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert.False?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

@@ -396,5 +396,16 @@ let DefiningEmptyStringsWithDoubleQuotes(fileInfo: FileInfo) =
fileText.Contains "\"\""

let ProjFilesNamingConvention(fileInfo: FileInfo) =
printfn "%s" fileInfo.FullName
false
let regex = new Regex("(.*)\..*proj$")
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also extra paren.

printfn "%s" fileInfo.FullName
false
let regex = new Regex("(.*)\..*proj$")
assert (regex.IsMatch fileInfo.FullName)
Copy link
Contributor

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

Copy link
Member

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

Copy link
Contributor

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?

Copy link
Contributor

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 🤔

Copy link
Member

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert.True?

Copy link
Member

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(
Copy link
Contributor

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(
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert.False?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

@@ -411,5 +411,31 @@ let ProjFilesNamingConvention(fileInfo: FileInfo) =
fileName <> parentDirectoryName

let NotFollowingNamespaceConvention(fileInfo: FileInfo) =
printfn "%s" fileInfo.FullName
false
assert (fileInfo.FullName.EndsWith(".fs"))
Copy link
Contributor

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" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mersho same here


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"
Copy link
Member

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"?

@Mersho Mersho force-pushed the verifyDotnetConventions-squashed branch from 1342e1d to 6e74482 Compare August 28, 2023 09:53
Mersho and others added 9 commits August 29, 2023 12:43
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.
@Mersho Mersho force-pushed the verifyDotnetConventions-squashed branch from 83803e8 to e124a91 Compare August 29, 2023 09:15
Mersho and others added 4 commits August 29, 2023 13:34
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>
@Mersho Mersho force-pushed the verifyDotnetConventions-squashed branch from 10b55f8 to 5358b96 Compare August 29, 2023 11:34
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.
@Mersho Mersho force-pushed the verifyDotnetConventions-squashed branch from 8fb77c7 to 18b828e Compare August 29, 2023 11:36
@knocte
Copy link
Member

knocte commented Aug 31, 2023

@Mersho CI is still red

@Mersho
Copy link
Contributor

Mersho commented Aug 31, 2023

@Mersho CI is red because it's failed to install nodejs

I don't have access to re-run CI, do you think I should re-push?

installing : node-v18.17.1
mkdir : /usr/local/n/versions/node/18.17.1
fetch : https://nodejs.org/dist/v18.17.1/node-v18.17.1-linux-x64.tar.gz
curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)

gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

  Error: failed to download archive for 18.17.1

Error: Process completed with exit code 1.

@knocte
Copy link
Member

knocte commented Aug 31, 2023

I don't have access to re-run CI,

Ask Zahra to give you access. The telegram channel is meant for this king of things.

do you think I should re-push?

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 :)

@knocte
Copy link
Member

knocte commented Aug 31, 2023

Next time you face a problem like this

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.

@knocte
Copy link
Member

knocte commented Aug 31, 2023

@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.

@Mersho
Copy link
Contributor

Mersho commented Aug 31, 2023

The pull request has been superseded by a newer one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants