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
9 changes: 8 additions & 1 deletion .github/workflows/cli-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ on:
- '.github/workflows/cli-scan.yaml'
- '.gitignore'
- 'comp-cli/**/*'
pull_request:
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/cli-scan.yaml'
- '.gitignore'
- 'comp-cli/**/*'


workflow_dispatch:

Expand All @@ -22,7 +29,7 @@ jobs:
name: SonarQube Scan for CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: sonarsource/sonarqube-scan-action@master
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/dotnet-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ on:
- '.gitignore'
- 'comp-dotnet/*.sln'
- 'comp-dotnet/project/*.cs*'
pull_request:
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/dotnet-scan.yaml'
- '.gitignore'
- 'comp-dotnet/*.sln'
- 'comp-dotnet/project/*.cs*'

workflow_dispatch:
jobs:
Expand All @@ -27,14 +34,14 @@ jobs:
with:
java-version: 17
- name: Cache SonarQube packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~\.sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube scanner
id: cache-sonar-scanner
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
Expand All @@ -51,4 +58,4 @@ jobs:
cd .\comp-dotnet
..\.sonar\scanner\dotnet-sonarscanner begin /k:"demo:mono-dotnet" /n:"Monorepo .Net Core" /d:sonar.plugins.downloadOnlyRequired=true /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}"
dotnet build dotnetcore-sample.sln
..\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
..\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
11 changes: 9 additions & 2 deletions .github/workflows/maven-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ on:
- '.gitignore'
- 'comp-maven/src/**/*'
- 'comp-maven/pom.xml'
pull_request:
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/maven-scan.yaml'
- '.gitignore'
- 'comp-maven/src/**/*'
- 'comp-maven/pom.xml'
workflow_dispatch:
jobs:
scan-maven:
Expand All @@ -28,13 +35,13 @@ jobs:
with:
java-version: 17
- name: Cache SonarQube packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ on:
- '.github/workflows/cli-scan.yaml'
- '.gitignore'
- 'comp-cli/**/*'
pull_request:
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/cli-scan.yaml'
- '.gitignore'
- 'comp-cli/**/*'
```

The SonarQube scan is run with `comp-cli` as the base directory.
Expand Down Expand Up @@ -49,6 +55,13 @@ on:
- '.gitignore'
- 'comp-dotnet/*.sln'
- 'comp-dotnet/project/*.cs*'
pull_request:
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/dotnet-scan.yaml'
- '.gitignore'
- 'comp-dotnet/*.sln'
- 'comp-dotnet/project/*.cs*'
```
The .NET build and SonarQube scan are run in the `comp-dotnet` directory.
```yaml
Expand All @@ -75,6 +88,13 @@ on:
- '.gitignore'
- 'comp-maven/src/**/*'
- 'comp-maven/pom.xml'
pull_request:
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/maven-scan.yaml'
- '.gitignore'
- 'comp-maven/src/**/*'
- 'comp-maven/pom.xml'
```
The Maven build and SonarQube scan are run in the `comp-maven` directory.
```yaml
Expand Down
4 changes: 1 addition & 3 deletions comp-cli/src/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ def __init__(self, first=None, last=None):
self.gender = None
self.religion = None
self.compensation = 0
return self

def store_religion(self, religion):
self.religion = religion

def compute_pay(self):
# TODO: something
# TODO: something
# TODO: something
if self.gender == Person.MALE:
self.compensation = SOME_VALUE
elif self.gender == Person.FEMALE:
Expand Down
2 changes: 2 additions & 0 deletions comp-dotnet/project/MyClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class MyClass
{
public string ReturnMessage()
{
int await = 42;
int async = 42;
return "Happy coding!";
}
}
Expand Down
2 changes: 1 addition & 1 deletion comp-dotnet/project/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace HelloWorld
{
class Program
static class Program
{
static void Main(string[] args)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
is_global = true
build_property.RootNamespace = dotnet_sample
build_property.ProjectDir = /Users/theil.bise/repos/monorepo/Monorepo-Example/comp-dotnet/project/
build_property.ProjectDir = /Users/theil.bise/repos/monorepo/GitHub-Monorepo-Example/comp-dotnet/project/
Binary file not shown.
25 changes: 17 additions & 8 deletions comp-maven/src/main/java/coverage_metrics/CoverageMetrics.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package coverage_metrics;

import java.security.SecureRandom;
import java.util.List;

/*
*
Expand Down Expand Up @@ -89,14 +90,22 @@ public static boolean all0sAnd1s(String val){
}
return all;
}
private int generateRandom() throws java.io.UnsupportedEncodingException{
SecureRandom sr = new SecureRandom();
sr.setSeed(123456L);
int v = sr.nextInt(32);

sr = new SecureRandom("abcdefghijklmnop".getBytes("us-ascii"));
v = sr.nextInt(32);
return v;

}

class Entity implements Cloneable { // Noncompliant, using `Cloneable`

public int value;
public List<Entity> children; // deep copy wanted

@Override
public Entity clone() {
try {
Entity copy = (Entity) super.clone(); // invariant not enforced, because no constructor is caled
copy.children = children.stream().map(Entity::clone).toList();
return copy;
} catch (CloneNotSupportedException e) { // this will not happen due to behavioral contract
throw new AssertionError();
}
}
}