From a8f357e51230763357a22b11939805b63f580ab3 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 23 Aug 2019 09:17:23 +0100 Subject: [PATCH 1/6] Add static analysis --- staticanalysis/cppcheck.groovy | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/staticanalysis/cppcheck.groovy b/staticanalysis/cppcheck.groovy index b3b997e..18df1cb 100644 --- a/staticanalysis/cppcheck.groovy +++ b/staticanalysis/cppcheck.groovy @@ -57,9 +57,17 @@ pipeline { script { def CPPCHECKFOLDER = "${STATICANALYSIS}/cppcheck" dir(CPPCHECKFOLDER) { - bat """ - "${CPPCHECK}" --xml --xml-version=2 "${SRC}" 2> cppcheck.xml - """ + if (isUnix()) { + sh """#!/bin/bash + set -e + + "${CPPCHECK}" --xml --xml-version=2 "${SRC}" 2> cppcheck.xml + """ + } else { + bat """ + "${CPPCHECK}" --xml --xml-version=2 "${SRC}" 2> cppcheck.xml + """ + } } recordIssues(tools: [ cppCheck(pattern: "**/cppcheck.xml", reportEncoding: 'UTF-8'), From bb4f70629ba6bf7f3058d608a8fad358fefb2f4a Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 23 Aug 2019 09:19:50 +0100 Subject: [PATCH 2/6] Add static analysis --- staticanalysis/cppcheck.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/staticanalysis/cppcheck.groovy b/staticanalysis/cppcheck.groovy index 18df1cb..54b683a 100644 --- a/staticanalysis/cppcheck.groovy +++ b/staticanalysis/cppcheck.groovy @@ -57,6 +57,7 @@ pipeline { script { def CPPCHECKFOLDER = "${STATICANALYSIS}/cppcheck" dir(CPPCHECKFOLDER) { + echo "Executing: "${CPPCHECK}" --xml --xml-version=2 "${SRC}" 2> cppcheck.xml" if (isUnix()) { sh """#!/bin/bash set -e From 24384288ed2784219716d0e6cb072be679a6214a Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 23 Aug 2019 09:21:39 +0100 Subject: [PATCH 3/6] Add static analysis --- staticanalysis/cppcheck.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cppcheck.groovy b/staticanalysis/cppcheck.groovy index 54b683a..59323c1 100644 --- a/staticanalysis/cppcheck.groovy +++ b/staticanalysis/cppcheck.groovy @@ -57,7 +57,7 @@ pipeline { script { def CPPCHECKFOLDER = "${STATICANALYSIS}/cppcheck" dir(CPPCHECKFOLDER) { - echo "Executing: "${CPPCHECK}" --xml --xml-version=2 "${SRC}" 2> cppcheck.xml" + echo "Executing: ${CPPCHECK} --xml --xml-version=2 ${SRC} 2> cppcheck.xml" if (isUnix()) { sh """#!/bin/bash set -e From b0a28652ef2ae8ed61ed660e8dc407707708f69b Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 23 Aug 2019 09:33:31 +0100 Subject: [PATCH 4/6] GIS-1621 - Update static analysis --- staticanalysis/ccm.groovy | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/staticanalysis/ccm.groovy b/staticanalysis/ccm.groovy index 290c897..aa697a6 100644 --- a/staticanalysis/ccm.groovy +++ b/staticanalysis/ccm.groovy @@ -63,9 +63,16 @@ pipeline { script { def CCMOLDER = "${STATICANALYSIS}/ccm" dir(CCMOLDER) { - bat """ - "${CCM}" "${SRC}" /xml /nummetrics=100 > ccm.xml - """ + if (isUnix()) { + sh """#!/bin/bash + # Uses mono + "${CCM}" "${SRC}" /xml /nummetrics=100 > ccm.xml + """ + } else { + bat """ + "${CCM}" "${SRC}" /xml /nummetrics=100 > ccm.xml + """ + } } recordIssues(tools: [ ccm(pattern: "**/ccm.xml", reportEncoding: 'UTF-8'), From 80cbc7c97d7042937d7f2a10f63f711bc79fc951 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 23 Aug 2019 09:52:21 +0100 Subject: [PATCH 5/6] Echo ccm command --- staticanalysis/ccm.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/staticanalysis/ccm.groovy b/staticanalysis/ccm.groovy index aa697a6..66a75e4 100644 --- a/staticanalysis/ccm.groovy +++ b/staticanalysis/ccm.groovy @@ -63,6 +63,7 @@ pipeline { script { def CCMOLDER = "${STATICANALYSIS}/ccm" dir(CCMOLDER) { + echo "Executing: ${CCM} ${SRC} /xml /nummetrics=100 > ccm.xml" if (isUnix()) { sh """#!/bin/bash # Uses mono From 7185c9f4ce98450db3400ecdd20bd373daac3f53 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Fri, 23 Aug 2019 21:51:00 +0100 Subject: [PATCH 6/6] Strip non C++ files before analysing --- staticanalysis/ccm.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/staticanalysis/ccm.groovy b/staticanalysis/ccm.groovy index 66a75e4..93e4711 100644 --- a/staticanalysis/ccm.groovy +++ b/staticanalysis/ccm.groovy @@ -66,6 +66,7 @@ pipeline { echo "Executing: ${CCM} ${SRC} /xml /nummetrics=100 > ccm.xml" if (isUnix()) { sh """#!/bin/bash + find "${SRC}" -type f ! -name "*.cpp" -a ! -name "*.h" -a ! -name "*.hpp" -a ! -name "*.c" -exec rm -r {} \; # Uses mono "${CCM}" "${SRC}" /xml /nummetrics=100 > ccm.xml """