Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# *.fsx,*.fs: formatting F# files using fantomless
df5cfb143c4efe73806ead91e5cddf4e133be0a8

# commitlint.config: split helper funcs and plugins
3008d6578aa484ae776b29c9246dca4eeae3418a

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ jobs:
run: dotnet fsi scripts/unpinnedDotnetPackageVersions.fsx
- name: Check there are no unpinned nuget package reference versions in F# scripts
run: dotnet fsi scripts/unpinnedNugetPackageReferenceVersions.fsx
- name: compares commit-msg with PR in case there is only one commit in the PR
if: github.event_name == 'pull_request'
run: dotnet fsi scripts/compareCommitMsgWithPR.fsx
- name: Check if gitPush1by1 was used
if: github.event_name == 'pull_request'
run: dotnet fsi scripts/detectNotUsingGitPush1by1.fsx
Expand Down
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This is a repository that contains several useful things that other `nblockchain
* [F# scripts compilation](scripts/compileFSharpScripts.fsx).
* [EOF without EOL detection](scripts/eofConvention.fsx).
* [Mixed line-endings detection](scripts/mixedLineEndings.fsx).
* [Compare commit-msg with PR (Making sure the commit message title and body are the same as PR title and description in case there is only one commit in the PR)](scripts/compareCommitMsgWithPR.fsx).
* Use of unpinned versions:
* [Use of `-latest` suffix in `runs-on:` GitHubCI tags](scripts/unpinnedGitHubActionsImageVersions.fsx).
* [Use of asterisk (*) in `PackageReference` items of .NET projects](scripts/unpinnedDotnetPackageVersions.fsx).
Expand Down
80 changes: 80 additions & 0 deletions WorkflowGuidelines.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,84 @@
# Workflow guidelines

* Avoid typical bad practices like:

* Magic numbers:

Avoid using unnamed numerical constants in software code, this practice makes code hard to understand and maintain.

Example:
```
var distance = GpsUtil.GetDistance()
if (distance < 100)
throw new NotImplementedException();
```
```
private const int MinimumSupportedDistanceToNotifyKillerDrones = 100;

...

var distance = GpsUtil.GetDistance()
if (distance < MinimumSupportedDistanceToNotifyKillerDrones)
throw new NotImplementedException();
```

* DRY (Don't Repeat Yourself):

The DRY principle suggests that a piece of information should only be stored once in a project and should be referenced as needed, rather than being copied and pasted multiple times throughout the codebase.

It has several benefits, including reducing the amount of code that needs to be written and maintained, improving the consistency and quality of the code, and reducing the risk of introducing errors and bugs when the information changes.

Example:
```
let preAuthInputMac =
CalculateMacWithSHA3256
preAuthInput
":hs_mac"

...

let authInputMac =
CalculateMacWithSHA3256
authInput
":hs_mac"
```
```
let AuthenticationDigestCalculationKey = ":hs_mac"

...

let preAuthInputMac =
CalculateMacWithSHA3256
preAuthInput
AuthenticationDigestCalculationKey

...

let authInputMac =
CalculateMacWithSHA3256
authInput
AuthenticationDigestCalculationKey
```

* Primitive Obsession:

Primitive Obsession is a situation where simple data types such as strings, integers, or arrays are overused in place of more appropriate objects.

Example:
```
let saveFilePath = System.Console.ReadLine()

let savedData = System.IO.File.ReadAllText saveFilePath
```
```
let saveFilePath =
let saveFilePathInString =
System.Console.ReadLine()
System.IO.FileInfo saveFilePathInString

let savedData = System.IO.File.ReadAllText saveFilePath.FullName
```

* When contributing a PullRequest, separate your commits in units of work
(don't mix changes that have different concerns in the same commit). Don't
forget to include all explanations and reasonings in the commit messages,
Expand Down Expand Up @@ -75,3 +154,4 @@ closed after the commit lands, then you would use the word `Closes` instead of
Do not use long lines (manually crop them with EOLs because git doesn't do this
automatically).


Loading