Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NodeClientSharedCode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Shared
NodeClientSharedCode
Compare revisions
59308a719fdee1a2025e90a18774d56fc6d11d9b to eedbe869a561f6e9a3b02fa9374cee425af27946
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
dojo_project/projects/shared/nodeclientsharedcode
Select target project
No results found
eedbe869a561f6e9a3b02fa9374cee425af27946
Select Git revision
Branches
ask-user-to-delete-exercises-on-duplicates
jw_sonar
jw_sonar_backup
main
move-to-esm-only
open_tool_for_self_hosting
v5.0
v6.0
Tags
v4.1
v4.2
10 results
Swap
Target
dojo_project/projects/shared/nodeclientsharedcode
Select target project
dojo_project/projects/shared/nodeclientsharedcode
1 result
59308a719fdee1a2025e90a18774d56fc6d11d9b
Select Git revision
Branches
ask-user-to-delete-exercises-on-duplicates
jw_sonar
jw_sonar_backup
main
move-to-esm-only
open_tool_for_self_hosting
v5.0
v6.0
Tags
v4.1
v4.2
10 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
SonarAnalyzer => Reformat
· eedbe869
michael.minelli
authored
2 months ago
eedbe869
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
helpers/Dojo/SonarAnalyzer.ts
+22
-28
22 additions, 28 deletions
helpers/Dojo/SonarAnalyzer.ts
with
22 additions
and
28 deletions
helpers/Dojo/SonarAnalyzer.ts
View file @
eedbe869
import
{
spawnSync
}
from
'
node:child_process
'
;
import
{
Language
}
from
'
../../models/Assignment
'
;
import
SharedConfig
from
'
../../../shared/config/SharedConfig
'
;
import
{
spawnSync
}
from
'
node:child_process
'
;
import
{
Language
}
from
'
../../models/Assignment
'
;
import
SharedConfig
from
'
../../../shared/config/SharedConfig
'
;
const
IMAGE_NAME
=
'
dojo-sonar-scanner
'
const
IMAGE_NAME
=
'
dojo-sonar-scanner
'
;
const
OUT_DIR
=
'
bw-output
'
;
class
SonarAnalyzer
{
buildDocker
=
()
=>
{
const
buildProcess
=
spawnSync
(
'
docker
'
,
[
'
build
'
,
'
--tag
'
,
IMAGE_NAME
,
'
/sonar
'
]);
const
buildProcess
=
spawnSync
(
'
docker
'
,
[
'
build
'
,
'
--tag
'
,
IMAGE_NAME
,
'
/sonar
'
]);
if
(
buildProcess
.
status
!==
0
)
{
console
.
log
(
buildProcess
.
stdout
.
toString
())
console
.
log
(
buildProcess
.
stderr
.
toString
())
console
.
log
(
buildProcess
.
stdout
.
toString
())
;
console
.
log
(
buildProcess
.
stderr
.
toString
())
;
return
false
;
}
return
true
;
}
}
;
mustRunBuild
=
(
language
:
Language
,
buildLine
:
string
|
undefined
)
=>
{
return
[
Language
.
c
,
Language
.
cpp
,
Language
.
objc
].
includes
(
language
)
&&
buildLine
!=
undefined
;
}
return
[
Language
.
c
,
Language
.
cpp
,
Language
.
objc
].
includes
(
language
)
&&
buildLine
!=
undefined
;
}
;
runBuildStep
=
(
buildLine
:
string
)
=>
{
const
process
=
spawnSync
(
`docker run -v ./:/usr/src
${
IMAGE_NAME
}
/usr/local/bin/build-wrapper-linux-x86-64 --out-dir
${
OUT_DIR
}
`
+
buildLine
,
[],
{
shell
:
true
})
const
process
=
spawnSync
(
`docker run -v ./:/usr/src
${
IMAGE_NAME
}
/usr/local/bin/build-wrapper-linux-x86-64 --out-dir
${
OUT_DIR
}
`
+
buildLine
,
[],
{
shell
:
true
})
;
if
(
process
.
status
!==
0
)
{
console
.
log
(
process
.
stdout
.
toString
())
console
.
log
(
process
.
stderr
.
toString
())
console
.
log
(
process
.
stdout
.
toString
())
;
console
.
log
(
process
.
stderr
.
toString
())
;
return
false
;
}
return
true
;
}
}
;
runAnalysis
=
(
sonarKey
:
string
,
language
:
Language
,
buildLine
:
string
|
undefined
)
=>
{
runAnalysis
=
(
sonarKey
:
string
,
language
:
Language
,
buildLine
:
string
|
undefined
)
:
boolean
=>
{
let
addParam
:
string
[]
=
[];
if
(
this
.
mustRunBuild
(
language
,
buildLine
))
{
addParam
=
[
`-Dsonar.cfamily.build-wrapper-output=/usr/src/
${
OUT_DIR
}
`
];
if
(
this
.
mustRunBuild
(
language
,
buildLine
)
)
{
addParam
=
[
`-Dsonar.cfamily.build-wrapper-output=/usr/src/
${
OUT_DIR
}
`
];
}
const
process
=
spawnSync
(
'
docker
'
,
[
'
run
'
,
'
-v
'
,
'
./:/usr/src
'
,
IMAGE_NAME
,
'
sonar-scanner
'
,
'
-Dsonar.qualitygate.wait=true
'
,
'
-Dsonar.projectKey=
'
+
sonarKey
,
'
-Dsonar.sources=.
'
,
'
-Dsonar.host.url=
'
+
SharedConfig
.
sonar
.
url
,
'
-Dsonar.login=
'
+
SharedConfig
.
sonar
.
token
,
...
addParam
])
const
process
=
spawnSync
(
'
docker
'
,
[
'
run
'
,
'
-v
'
,
'
./:/usr/src
'
,
IMAGE_NAME
,
'
sonar-scanner
'
,
'
-Dsonar.qualitygate.wait=true
'
,
'
-Dsonar.projectKey=
'
+
sonarKey
,
'
-Dsonar.sources=.
'
,
'
-Dsonar.host.url=
'
+
SharedConfig
.
sonar
.
url
,
'
-Dsonar.login=
'
+
SharedConfig
.
sonar
.
token
,
...
addParam
]);
return
process
.
status
===
0
;
}
}
;
}
export
default
new
SonarAnalyzer
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.