Skip to content

Commit

Permalink
GSAGH-521: Setup local coverage check and pre commit hooks (#690)
Browse files Browse the repository at this point in the history
* feat: fixing the relative paths to path from c: on the GSA install folder

* Update jira-check-branch.yml

* feat: fixed bitwise to boolean operations

* feat: removed invalid options and reformated the .editorconfig

* feat: added gitignore for .venv and config for pre-commit

* feat: removed the case sensitivity check

* feat: formated usings to include groups

* feat: added coverage file

* feat: updated typo on coverage and removed build step on pre-config

* ci: debugging pre-commit coverage

* ci: fix end of files and trailing whitespace

* feat: formated GSA.GH project
  • Loading branch information
psarras authored Aug 16, 2024
1 parent bd6e511 commit 7b4465f
Show file tree
Hide file tree
Showing 846 changed files with 3,551 additions and 896 deletions.
96 changes: 49 additions & 47 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ tab_width = 1

# New line preferences
end_of_line = lf
insert_final_newline = true:error
insert_final_newline = true

#### .NET Coding Conventions ####

# Organize usings
dotnet_separate_import_directive_groups = true:error
dotnet_sort_system_directives_first = true:error
dotnet_separate_import_directive_groups = true
dotnet_sort_system_directives_first = true
file_header_template = unset

# this. and Me. preferences
Expand Down Expand Up @@ -48,7 +48,7 @@ dotnet_style_explicit_tuple_names = true:error
dotnet_style_namespace_match_folder = true:error
dotnet_style_null_propagation = true:error
dotnet_style_object_initializer = true:error
dotnet_style_operator_placement_when_wrapping = beginning_of_line:error
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_prefer_auto_properties = true:error
dotnet_style_prefer_compound_assignment = true:error
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
Expand Down Expand Up @@ -139,45 +139,45 @@ csharp_style_allow_embedded_statements_on_same_line_experimental = true:error
#### C# Formatting Rules ####

# New line preferences
csharp_new_line_before_open_brace = none:error
csharp_new_line_before_catch = false:error
csharp_new_line_before_else = false:error
csharp_new_line_before_finally = false:error
csharp_new_line_before_members_in_anonymous_types = false:error
csharp_new_line_before_members_in_object_initializers = false:error
csharp_new_line_between_query_expression_clauses = false:error
csharp_new_line_before_open_brace = none
csharp_new_line_before_catch = false
csharp_new_line_before_else = false
csharp_new_line_before_finally = false
csharp_new_line_before_members_in_anonymous_types = false
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_between_query_expression_clauses = false

# Indentation preferences
csharp_indent_block_contents = true:error
csharp_indent_braces = false:error
csharp_indent_case_contents = true:error
csharp_indent_case_contents_when_block = true:error
csharp_indent_labels = one_less_than_current:error
csharp_indent_switch_labels = true:error
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_labels = no_change
csharp_indent_switch_labels = true

# Space preferences
csharp_space_after_cast = false:error
csharp_space_after_colon_in_inheritance_clause = true:error
csharp_space_after_comma = true:error
csharp_space_after_dot = false:error
csharp_space_after_keywords_in_control_flow_statements = true:error
csharp_space_after_semicolon_in_for_statement = true:error
csharp_space_around_binary_operators = before_and_after:error
csharp_space_around_declaration_statements = false:error
csharp_space_before_colon_in_inheritance_clause = true:error
csharp_space_before_comma = false:error
csharp_space_before_dot = false:error
csharp_space_before_open_square_brackets = false:error
csharp_space_before_semicolon_in_for_statement = false:error
csharp_space_between_empty_square_brackets = false:error
csharp_space_between_method_call_empty_parameter_list_parentheses = false:error
csharp_space_between_method_call_name_and_opening_parenthesis = false:error
csharp_space_between_method_call_parameter_list_parentheses = false:error
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false:error
csharp_space_between_method_declaration_name_and_open_parenthesis = false:error
csharp_space_between_method_declaration_parameter_list_parentheses = false:error
csharp_space_between_parentheses = false:error
csharp_space_between_square_brackets = false:error
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# Wrapping preferences
csharp_preserve_single_line_blocks = true
Expand All @@ -203,26 +203,26 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

# ReSharper properties
Expand Down Expand Up @@ -345,3 +345,5 @@ resharper_place_field_attribute_on_same_line = if_owner_is_single_line
resharper_place_linq_into_on_new_line = false
resharper_remove_blank_lines_near_braces_in_declarations = false
resharper_alignment_tab_fill_style = use_spaces
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
csharp_style_prefer_primary_constructors = true:suggestion
2 changes: 1 addition & 1 deletion .github/workflows/github-release-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:

- name: Push nupkg file to nuget.org
run: |
dotnet nuget push "*.nupkg" --api-key ${{ SECRETS.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
dotnet nuget push "*.nupkg" --api-key ${{ SECRETS.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
2 changes: 1 addition & 1 deletion .github/workflows/jira-check-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
- uses: arup-group/actions-composite-oasys-jira-check/branch@main
if: startsWith( github.ref, 'refs/heads/release') == false
with:
valid-branch-names: task|test|bugfix|feature|hotfix|epic
valid-branch-names: task|test|bugfix|feature|hotfix|epic|feat
jira-username: [email protected]
jira-password: ${{ secrets.JIRA_PASSWORD }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

.venv/
results/

# User-specific files
*.rsuser
*.suo
Expand Down
40 changes: 40 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
default_stages: [pre-commit]

repos:
- repo: local
hooks:

- id: dotnet-format
name: Format
entry: dotnet format --exclude-diagnostics --verify-no-changes --verbosity diagnostic
language: system
pass_filenames: false
always_run: true

- id: dotnet-test-coverage
name: Run dotnet tests with coverage
entry: powershell.exe -NoProfile -ExecutionPolicy Bypass -File coverage.ps1
stages: [pre-commit]
language: system
pass_filenames: false

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.13.0
hooks:
- id: commitizen
stages: [commit-msg]

# this should go last since it will fix line endings broken by other tools
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
#- id: check-case-conflict
- id: check-yaml
- id: check-ast
- id: check-merge-conflict
- id: double-quote-string-fixer
- id: trailing-whitespace
exclude: .github
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
2 changes: 2 additions & 0 deletions DocsGeneration/Data/Component.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;

using DocsGeneration.Data.Helpers;

using Grasshopper.Kernel;

namespace DocsGeneration.Data {
Expand Down
6 changes: 4 additions & 2 deletions DocsGeneration/Data/Parameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
using System.Reflection;
using System.Text.RegularExpressions;
using System.Xml;

using DocsGeneration.Data.Helpers;
using DocsGeneration.Helpers;

using Grasshopper.Kernel;

using OasysUnits;

namespace DocsGeneration.Data {
Expand Down Expand Up @@ -156,8 +159,7 @@ public static List<Parameter> GetParameters(Type[] typelist, List<Component> com
parameters.Add(param);
Console.WriteLine($"Added {param.Name} parameter");
}
}
catch (Exception) {
} catch (Exception) {
continue;
}
}
Expand Down
2 changes: 2 additions & 0 deletions DocsGeneration/MarkDowns/Components.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;

using DocsGeneration.Data;
using DocsGeneration.MarkDowns.Helpers;

using GsaGH.Components.Helpers;
using GsaGH.Helpers;

Expand Down
2 changes: 2 additions & 0 deletions DocsGeneration/MarkDowns/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

using DocsGeneration.Data;

using GsaGH.Helpers;

namespace DocsGeneration.MarkDowns.Helpers {
Expand Down
1 change: 1 addition & 0 deletions DocsGeneration/MarkDowns/Parameters.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;

using DocsGeneration.Data;
using DocsGeneration.MarkDowns.Helpers;

Expand Down
1 change: 1 addition & 0 deletions DocsGeneration/MarkDowns/SideBar.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;

using DocsGeneration.Data;
using DocsGeneration.MarkDowns.Helpers;

Expand Down
2 changes: 1 addition & 1 deletion DocsGeneration/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;

using DocsGeneration.Data;
using DocsGeneration.Helpers;
using DocsGeneration.MarkDowns.Helpers;
Expand Down Expand Up @@ -33,4 +34,3 @@ public static void Main() {
}
}
}

4 changes: 4 additions & 0 deletions DocsGeneration/Setup/GrasshopperFixture.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using System;
using System.IO;
using System.Reflection;

using Grasshopper.Plugin;

using OasysGH.Units;

using Rhino;
using Rhino.Runtime.InProcess;

using RhinoInside;

namespace DocsGeneration {
Expand Down
4 changes: 2 additions & 2 deletions ExampleFiles/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example Files

This folder contains a number of example files for GSA-Grasshopper plugin.
This folder contains a number of example files for GSA-Grasshopper plugin.

## Samples

Expand All @@ -12,7 +12,7 @@ GsaGH is based on GsaAPI, feel free to copy the code from this repo or check out

## Unit tests

All files in this folder and subfolders forms part of the GsaGH project's unit testing ('Integration Tests'). The files are run and verified as part of all new releases.
All files in this folder and subfolders forms part of the GsaGH project's unit testing ('Integration Tests'). The files are run and verified as part of all new releases.

![tests](https://github.com/arup-group/GSA-Grasshopper/assets/25223248/9001e00f-37a2-4860-b8ec-4714b2b232d0)

Expand Down
5 changes: 5 additions & 0 deletions GsaGH/Components/0_Model/CreateGridLine.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
using System;
using System.Drawing;

using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;

using GsaGH.Helpers.GH;
using GsaGH.Parameters;
using GsaGH.Properties;

using OasysGH;
using OasysGH.Components;

using Rhino.Geometry;

using Line = Rhino.Geometry.Line;

namespace GsaGH.Components {
Expand Down
3 changes: 3 additions & 0 deletions GsaGH/Components/0_Model/CreateList.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using System.Drawing;

using Grasshopper.Kernel;

using GsaGH.Helpers.GH;
using GsaGH.Parameters;
using GsaGH.Properties;

using OasysGH;
using OasysGH.Components;

Expand Down
5 changes: 5 additions & 0 deletions GsaGH/Components/0_Model/CreateModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

using GH_IO.Serialization;

using Grasshopper.Kernel;

using GsaGH.Helpers;
using GsaGH.Helpers.Assembly;
using GsaGH.Helpers.GH;
using GsaGH.Helpers.Import;
using GsaGH.Parameters;
using GsaGH.Properties;

using OasysGH;
using OasysGH.Components;
using OasysGH.UI;
using OasysGH.Units;
using OasysGH.Units.Helpers;

using OasysUnits;
using OasysUnits.Units;

Expand Down
Loading

0 comments on commit 7b4465f

Please sign in to comment.