-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2536386
Showing
8 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.sonarqube/ | ||
bin/ | ||
.vs/ | ||
.DS_Store | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright 2017 Joshua Quek | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
// Console.WriteLine("Hello, World!"); | ||
|
||
using System; | ||
using System.Linq; | ||
using System.IO; | ||
using System.Text; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
/** | ||
* Auto-generated code below aims at helping you parse | ||
* the standard input according to the problem statement. | ||
**/ | ||
class Solution | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
int N = int.Parse(Console.ReadLine()); // Number of elements which make up the association table. | ||
int Q = int.Parse(Console.ReadLine()); // Number Q of file names to be analyzed. | ||
//This will use the file Ext as the Key and the MIME type as the value. | ||
Dictionary <string, string> fileExtention = new Dictionary<string, string>(); | ||
List<string> fileName = new List<string>(); | ||
for (int i = 0; i < N; i++) | ||
{ | ||
string[] inputs = Console.ReadLine().Split(' '); | ||
string EXT = inputs[0].ToLower(); // file extension | ||
string MT = inputs[1]; // MIME type. | ||
fileExtention.Add(EXT, MT); | ||
} | ||
for (int i = 0; i < Q; i++) | ||
{ | ||
string FNAME = Console.ReadLine();// One file name per line. | ||
FNAME = FNAME.ToLower(); | ||
if (FNAME.Contains('.')) | ||
{ | ||
FNAME = FNAME.Substring(FNAME.LastIndexOf('.')+1); | ||
} | ||
else | ||
{ | ||
FNAME = "N/A"; | ||
} | ||
fileName.Add(FNAME); | ||
} | ||
|
||
foreach(string extention in fileName) | ||
{ | ||
if(extention == "N/A") | ||
{ | ||
Console.WriteLine("UNKNOWN"); | ||
} | ||
else if (fileExtention.ContainsKey(extention)) | ||
{ | ||
string MIMETypeToReturn = string.Empty; | ||
fileExtention.TryGetValue(extention, out MIMETypeToReturn); | ||
Console.WriteLine(MIMETypeToReturn); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("UNKNOWN"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Dotnetcore App | ||
A sample dotnetcore app to showcase SonarQube scanning. | ||
|
||
## Description | ||
|
||
Please refer to the `scanner-csharp.sh` file for the cli commands to scan this project. | ||
|
||
Alternatively, you can also use Azure DevOps pipelines to do the scan - refer to the `azure-pipelines.yml` file for this. | ||
|
||
## License | ||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
trigger: | ||
- main | ||
|
||
pool: | ||
vmImage: 'windows-latest' | ||
|
||
variables: | ||
solution: '**/*.sln' | ||
buildPlatform: 'Any CPU' | ||
buildConfiguration: 'Release' | ||
|
||
steps: | ||
|
||
# Prepare Analysis Configuration task | ||
- task: SonarQubePrepare@5 | ||
inputs: | ||
SonarQube: 'joshua-sonarqube' # SonarQube service connection id (found in Azure DevOps) | ||
scannerMode: 'MSBuild' | ||
projectKey: 'dotnetcore-azuredevops_dotnetcore-azuredevops_AYbAf9qWAu8T8ZieRlfh' | ||
projectName: 'dotnetcore-sonar-azuredevops' | ||
|
||
# Dotnet build task | ||
- task: DotNetCoreCLI@2 | ||
displayName: 'dotnet build' | ||
|
||
# Run Code Analysis task | ||
- task: SonarQubeAnalyze@5 | ||
|
||
# Publish Quality Gate Result task | ||
- task: SonarQubePublish@5 | ||
inputs: | ||
pollingTimeoutSec: '300' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<RootNamespace>dotnetcore_sonar</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 25.0.1705.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetcore-sonar", "dotnetcore-sonar.csproj", "{08FF83ED-E3E2-45AE-BB7B-5A9E4673EFBE}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{08FF83ED-E3E2-45AE-BB7B-5A9E4673EFBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{08FF83ED-E3E2-45AE-BB7B-5A9E4673EFBE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{08FF83ED-E3E2-45AE-BB7B-5A9E4673EFBE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{08FF83ED-E3E2-45AE-BB7B-5A9E4673EFBE}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {09EF56C3-9F1A-48BD-8FA0-5ED3401123EF} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
dotnet restore | ||
dotnet sonarscanner begin /k:"csharp-dotnetcore-sonar" /n:"csharp-dotnetcore-sonar" /d:sonar.verbose=true /d:sonar.login="input your token here" | ||
dotnet build | ||
dotnet sonarscanner end /d:sonar.login="input your token here" |