Skip to content

Commit

Permalink
Create codeql-analysis.yml (#1345)
Browse files Browse the repository at this point in the history
-Add CodeQL code scanner
-EnableNetAnalyzers
-small tweak for .editorconfig
  • Loading branch information
mregen committed Apr 1, 2021
1 parent 89da78d commit 25e0998
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ csharp_style_conditional_delegate_call =

# Modifier preferences
# require braces to be on a new line for control_blocks, types, and methods (also known as "Allman" style)
csharp_new_line_before_open_brace = control_blocks, types, methods, properties, accessors
csharp_new_line_before_open_brace = control_blocks, types, methods, properties, accessors, object_collection
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async : suggestion
csharp_new_line_before_catch = true
csharp_new_line_before_else = true : suggestion
Expand Down Expand Up @@ -117,7 +117,6 @@ csharp_prefer_braces =
csharp_style_deconstructed_variable_declaration = true : suggestion
csharp_prefer_simple_default_expression = true : suggestion
csharp_style_inlined_variable_declaration = false : suggestion
dotnet_style_predefined_type_for_member_access = false : suggestion

#Style - implicit and explicit types
csharp_style_var_for_built_in_types = false : silent
Expand All @@ -129,6 +128,7 @@ csharp_style_var_elsewhere =
#prefer the language keyword for local variables, method parameters, and class members,
#instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_locals_parameters_members = true : suggestion
dotnet_style_predefined_type_for_member_access = true : suggestion

#Style - qualification options
dotnet_style_qualification_for_event = false : suggestion
Expand Down Expand Up @@ -159,6 +159,9 @@ dotnet_style_prefer_auto_properties =
dotnet_style_prefer_conditional_expression_over_assignment = true : suggestion
dotnet_style_prefer_conditional_expression_over_return = true : suggestion

# 'using' directive preferences
csharp_using_directive_placement = outside_namespace:silent

# Naming rules

# Private Constants are PascalCase and start with k
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# A CodeQL query for the UA .NET Standard project
name: "CodeQL"

on:
push:
branches: [ master, release/* ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '30 6 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
1 change: 1 addition & 0 deletions Libraries/Opc.Ua.Client/Opc.Ua.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<RootNamespace>Opc.Ua.Client</RootNamespace>
<Description>OPC UA Client Class Library</Description>
<IsPackable>true</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions Libraries/Opc.Ua.Configuration/Opc.Ua.Configuration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<RootNamespace>Opc.Ua.Configuration</RootNamespace>
<Description>OPC UA Configuration Class Library</Description>
<IsPackable>true</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<RootNamespace>Opc.Ua.Security.Certificates</RootNamespace>
<Description>OPC UA Security X509 Certificates Class Library</Description>
<IsPackable>true</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions Libraries/Opc.Ua.Server/Opc.Ua.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<Description>OPC UA Server Class Library</Description>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<IsPackable>true</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions Stack/Opc.Ua.Core/Opc.Ua.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<RootNamespace>Opc.Ua</RootNamespace>
<Description>OPC UA Core Class Library</Description>
<IsPackable>true</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion version.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<ItemGroup Condition="$(NBGV_PublicRelease) != 'True'">
<ItemGroup Condition="$(NBGV_PublicRelease) != 'True' AND '$(CODEQL_RUNNER)' == ''">
<!-- Note: Keep Version 3.2.31, it is known working for 4 digit versioning -->
<PackageReference Include="Nerdbank.GitVersioning" Version="3.2.31">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit 25e0998

Please sign in to comment.