Skip to content

Commit

Permalink
Merge branch 'main' into add-super-linter
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmurillo authored Jun 24, 2024
2 parents c57fd0e + 932cc3d commit 3e44716
Show file tree
Hide file tree
Showing 75 changed files with 1,035 additions and 229 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"nbgv": {
"version": "3.6.133",
"version": "3.6.139",
"commands": [
"nbgv"
],
Expand Down
33 changes: 32 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ dotnet_style_readonly_field = true:warning

# Parameter preferences
dotnet_code_quality_unused_parameters = all:suggestion
# AV1561: Signature contains too many parameters
dotnet_diagnostic.AV1561.severity = suggestion

# Suppression preferences
dotnet_remove_unnecessary_suppression_exclusions = none

# XMLDocs preferences
# SA1600: Elements should be documented. We disable this it requires xmldocs for _all_ members. CS1591 already covers documenting public members.
dotnet_diagnostic.SA1600.severity = silent
# AV2305: Missing XML comment for internally visible type, member or parameter
dotnet_diagnostic.AV2305.severity = silent

#### C# Coding Conventions ####
[*.cs]
Expand Down Expand Up @@ -238,6 +242,9 @@ dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase
dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion
dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields
dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase
# SA1309: Field names must not begin with underscore
# Keep this aligned with `dotnet_naming_rule.private_fields_should_be__camelcase.style`
dotnet_diagnostic.SA1309.severity = none

dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion
dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields
Expand Down Expand Up @@ -381,7 +388,31 @@ dotnet_naming_style.s_camelcase.required_suffix =
dotnet_naming_style.s_camelcase.word_separator =
dotnet_naming_style.s_camelcase.capitalization = camel_case

# AV1580: Method argument calls a nested method
# Because debugger breakpoints cannot be set inside expressions, avoid overuse of nested method calls.
# Example: string result = ConvertToXml(ApplyTransforms(ExecuteQuery(GetConfigurationSettings(source))));
# requires extra steps to inspect intermediate method return values. On the other hard, were this expression broken into intermediate variables, setting a breakpoint on one of them would be sufficient.
#
# This is moved to silent because it's flagging foo.AsSpan()
dotnet_diagnostic.AV1580.severity = silent

# MA0040: Forward the CancellationToken parameter to methods that take one
dotnet_diagnostic.MA0040.severity = error
# Async analyzer
dotnet_diagnostic.CA2016.severity = error
dotnet_diagnostic.CA2016.severity = error

# AV1555: Avoid using named arguments
# Disabled because it's common to use a named argument when passing `null` or bool arguments to make the parameter's purpose clear
dotnet_diagnostic.AV1555.severity = none

#### Handling TODOs ####
# This is a popular rule in analyzers. Everyone has an opinion and
# some of the severity levels conflict. We don't need all of these
# to fire, only one. Pick one and mark it as informational so we
# don't lose track.
# S1135: Track uses of "TODO" tags
dotnet_diagnostic.S1135.severity = suggestion
# AV2318: Work-tracking TODO comment should be removed
dotnet_diagnostic.AV2318.severity = none
# MA0026: Fix TODO comment
dotnet_diagnostic.MA0026.severity = none
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "daily"
time: "08:00"
open-pull-requests-limit: 10
- package-ecosystem: nuget
directory: "/"
schedule:
interval: "daily"
time: "08:30"
ignore:
# Microsoft.CodeAnalysis.* packages defined in the analyzer project can impact compatibility with older SDKs for
# our users. We don't want to bump these without first considering the user impact.
#
# We don't wildcard Microsoft.CodeAnalysis.* here though, as there are testing libraries and analyzers that
# can be upgraded without impacting our users.
- dependency-name: "Microsoft.CodeAnalysis.CSharp"
- dependency-name: "Microsoft.CodeAnalysis.CSharp.Workspaces"
- dependency-name: "Microsoft.CodeAnalysis.Common"
- dependency-name: "Microsoft.CodeAnalysis.Workspaces.Common"
36 changes: 36 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Add 'build' label to any change in the 'build' directory
build:
- changed-files:
- any-glob-to-any-file: 'build/**/*'

# Add 'dependencies' label to any change in one of the packages files
dependencies:
- changed-files:
- any-glob-to-any-file: ['build/**/Packages.props', 'Directory.Packages.props']

# Add 'documentation' label to any change within the 'docs' directory or any '.md' file
documentation:
- changed-files:
- any-glob-to-any-file: ['docs/**', '**/*.md']

# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name
feature:
- head-branch: ['^feature', 'feature']

# Add 'bug' label to any PR where the head branch name starts with `bug` or has a `bug` section in the name
bug:
- head-branch: ['^bug', 'bug']

# Add 'releasable' label to any PR that is opened against the `main` branch
releasable:
- base-branch: 'main'

# Add 'github_actions' label to any change to one of the GitHub workflows or configuration files
github_actions:
- changed-files:
- any-glob-to-any-file: ['.github/workflows/*.yml', '.github/dependabot.yml', '.github/labeler.yml']

# Add 'analyzers' label to any change to an analyzer, code fix, or shipping documentation
analyzers:
- changed-files:
- any-glob-to-any-file: ['src/Moq.Analyzers/AnalyzerReleases.*.md', 'src/Moq.Analyzers/**/*Analyzer.cs', 'src/Moq.Analyzers/**/*CodeFix.cs']
50 changes: 50 additions & 0 deletions .github/workflows/label-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will read information about an issue and attempt to label it initially for triage and sorting

name: Label issues
on:
issues:
types:
- reopened
- opened

jobs:
label_issues:
name: "Issue: add labels"
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_ACTIONS_PR_WRITE }}
script: |
// Get the issue body and title
const body = context.payload.issue.body
let title = context.payload.issue.title
// Define the labels array
let labels = ["triage"]
// Check if the body or the title contains the word 'PowerShell' (case-insensitive)
if ((body != null && body.match(/powershell/i)) || (title != null && title.match(/powershell/i))) {
// Add the 'powershell' label to the array
labels.push("powershell")
}
// Check if the body or the title contains the words 'dotnet', '.net', 'c#' or 'csharp' (case-insensitive)
if ((body != null && body.match(/.net/i)) || (title != null && title.match(/.net/i)) ||
(body != null && body.match(/dotnet/i)) || (title != null && title.match(/dotnet/i)) ||
(body != null && body.match(/C#/i)) || (title != null && title.match(/C#/i)) ||
(body != null && body.match(/csharp/i)) || (title != null && title.match(/csharp/i))) {
// Add the '.NET' label to the array
labels.push(".NET")
}
// Add the labels to the issue
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
});
21 changes: 21 additions & 0 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Label PR
on: [pull_request_target]

jobs:
add_label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GH_ACTIONS_PR_WRITE }}"
16 changes: 15 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
push:
branches:
- main
merge_group:
branches:
- main

workflow_call: # Allow to be called from the release workflow
schedule:
- cron: '31 15 * * 0' # Run periodically to keep CodeQL database updated
Expand All @@ -26,6 +30,9 @@ jobs:

runs-on: ${{ matrix.os }}

env:
IS_COVERAGE_ALLOWED: ${{ secrets.CODACY_PROJECT_TOKEN != '' }}

steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -81,10 +88,17 @@ jobs:
name: .NET Code Coverage Reports (${{ matrix.os }})
path: "artifacts/TestResults/coverage/**"

- name: Publish coverage summary
- name: Publish coverage summary to GitHub
run: cat artifacts/TestResults/coverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
shell: bash

- name: Upload coverage data to Codacy
if: ${{ runner.os == 'Linux' && env.IS_COVERAGE_ALLOWED == 'true' }}
uses: codacy/codacy-coverage-reporter-action@v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ${{ github.workspace }}/artifacts/TestResults/coverage/Cobertura.xml

- name: Upload binlogs
uses: actions/upload-artifact@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.1" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
<PackageVersion Include="GetPackFromProject" Version="1.0.6" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.133" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.139" />
</ItemGroup>
</Project>
10 changes: 8 additions & 2 deletions Moq.Analyzers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34928.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Analyzers", "Source\Moq.Analyzers\Moq.Analyzers.csproj", "{41ECC571-F586-460A-9BED-23528C8210C4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Analyzers", "src\Moq.Analyzers\Moq.Analyzers.csproj", "{41ECC571-F586-460A-9BED-23528C8210C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Analyzers.Test", "Source\Moq.Analyzers.Test\Moq.Analyzers.Test.csproj", "{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Analyzers.Test", "tests\Moq.Analyzers.Test\Moq.Analyzers.Test.csproj", "{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moq.Analyzers.Benchmarks", "tests\Moq.Analyzers.Benchmarks\Moq.Analyzers.Benchmarks.csproj", "{11B3412F-456C-452E-94D2-B42D5C52F61C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,6 +23,10 @@ Global
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2348836-7129-4BE5-8AE6-D05FC8C28FC1}.Release|Any CPU.Build.0 = Release|Any CPU
{11B3412F-456C-452E-94D2-B42D5C52F61C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11B3412F-456C-452E-94D2-B42D5C52F61C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11B3412F-456C-452E-94D2-B42D5C52F61C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11B3412F-456C-452E-94D2-B42D5C52F61C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[![NuGet Version](https://img.shields.io/nuget/v/Moq.Analyzers?style=flat&logo=nuget&color=blue)](https://www.nuget.org/packages/Moq.Analyzers)
[![NuGet Downloads](https://img.shields.io/nuget/dt/Moq.Analyzers?style=flat&logo=nuget)](https://www.nuget.org/packages/Moq.Analyzers)
[![Main build](https://github.com/rjmurillo/moq.analyzers/actions/workflows/main.yml/badge.svg)](https://github.com/rjmurillo/moq.analyzers/actions/workflows/main.yml)
[![Codacy Grade Badge](https://app.codacy.com/project/badge/Grade/fc7c184dcb1843d4b1ae1b926fb82d5a)](https://app.codacy.com/gh/rjmurillo/moq.analyzers/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Codacy Coverage Badge](https://app.codacy.com/project/badge/Coverage/fc7c184dcb1843d4b1ae1b926fb82d5a)](https://app.codacy.com/gh/rjmurillo/moq.analyzers/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)

**Moq.Analyzers** is a Roslyn analyzer that helps you to write unit tests using the popular
[Moq](https://github.com/devlooped/moq) framework. Moq.Analyzers protects you from common mistakes and warns you if
Expand Down
23 changes: 0 additions & 23 deletions Source/Moq.Analyzers.Test/PackageTests.cs

This file was deleted.

Loading

0 comments on commit 3e44716

Please sign in to comment.