Commit 9e3a39fe authored by Ludan Stoecklé's avatar Ludan Stoecklé

sonarqube

parent d7b5d8a1
......@@ -4,9 +4,11 @@ testing
node_modules
lib-cov
coverage
.nyc_output
cov-pt*
npm-debug.log
**/test/output*
**/test/temp
.release.json
lerna-debug.log
dist
stages:
- code_build
- unit_test
- sonar_check
- code_publish
- docker_build
- docker_test
- docker_release
# stuff for some steps only
.template_for_docker: &template_for_docker
......@@ -24,6 +25,10 @@ variables:
DOCKER_CLI_ROOT: ${DOCKER_REGISTRY}/cli
DOCKER_SERVER_ROOT: ${DOCKER_REGISTRY}/server
DOCKER_TEST_TAG: test_${CI_COMMIT_REF_SLUG}
# sonar default stuff
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
# code build and publish
......@@ -43,22 +48,60 @@ build_the_code:
- lerna bootstrap --concurrency 8
- rm -f packages/rosaenlg/dist/rollup/*.js
- lerna run build
artifacts:
paths:
- packages/*/resources_pub
- packages/*/dist
- packages/
expire_in: 1 day
# except:
# - master
test_the_code:
stage: unit_test
image: node
cache:
paths:
- node_modules/
- packages/*/node_modules
untracked: true
script:
- npm -v
- node --version
- npm install -g lerna
- lerna bootstrap --concurrency 8
- lerna run test
artifacts:
paths:
- packages/*/resources_pub
- packages/*/dist
- packages/*/coverage
- packages/
expire_in: 1 day
except:
- master
# except:
# - master
sonarcloud_check:
stage: sonar_check
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
# except:
# - master
publish_on_npm:
stage: code_publish
image: node
script:
- npm install -g lerna
- npm install -g snyk
- snyk auth $SNYK_TOKEN
# - npm install -g snyk
# - snyk auth $SNYK_TOKEN
- npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
- npm config set always-auth=true
- npm config set [email protected]
......
.DS_Store
node_modules
/dist
# local env files
.env.local
......
sonar.projectName=browser-ide-demo
sonar.sources=src
sonar.exclusions=src/assets/**/*
<template>
<div class="editor">
<!-- direct @input="$emit..." does not work -->
<!-- direct @input="$emit..." does not work //NOSONAR
-->
<codemirror :options="cmOption" :value="initialCode" @input="onCmCodeChange"></codemirror>
</div>
</template>
......
......@@ -85,7 +85,7 @@ export default {
}
.renderedHtml {
font-family: Arial;
font-family: Arial, Helvetica, sans-serif;
}
.renderedPre {
......
......@@ -171,9 +171,6 @@ export default {
}
</script>
<style scoped>
</style>
<style>
#app {
padding-left: 250px;
......
......@@ -4,65 +4,68 @@ import * as fs from 'fs';
export function processEnglishAAn(inputFolder: string, outputFile: string, cb: Function): void {
console.log('starting to process WordNet: ' + inputFolder);
if (fs.existsSync(outputFile)) {
fs.unlinkSync(outputFile);
}
const outputStream: fs.WriteStream = fs.createWriteStream(outputFile);
const an = [];
const an: string[] = [];
const reGeneral = new RegExp('[^\\w]an [\\w]+', 'g');
const reDetail = new RegExp('[^\\w]an ([\\w]+)');
fs.readdir(inputFolder, (err, files) => {
const todo = [...files];
fs.readdir(inputFolder, (_readdirErr, files) => {
const promises: Promise<void>[] = [];
for (let i = 0; i < files.length; i++) {
const file = files[i];
const inputFile = inputFolder + '/' + file;
const promise = new Promise<void>((resolve, reject) => {
const file = files[i];
const inputFile = inputFolder + '/' + file;
let count = 0;
console.log(`reading file: ${inputFile}...`);
let count = 0;
console.log(`start reading file: ${inputFile}...`);
try {
const lineReader: ReadLine = createInterface({
input: fs.createReadStream(inputFile),
});
try {
const lineReader: ReadLine = createInterface({
input: fs.createReadStream(inputFile),
});
lineReader
.on('line', function (line: string): void {
const matched = line.match(reGeneral);
if (matched) {
for (let j = 0; j < matched.length; j++) {
const detail = matched[j].match(reDetail);
lineReader
.on('line', function(line: string): void {
const matched = line.match(reGeneral);
if (matched) {
for (let j = 0; j < matched.length; j++) {
const detail = matched[j].match(reDetail);
// keep the case
const word = detail[1];
if (an.indexOf(word) == -1) {
an.push(word);
}
// keep the case
const word = detail[1];
if (an.indexOf(word) == -1) {
an.push(word);
count++;
}
count++;
}
}
})
.on('close', function(): void {
console.log(`${file}: extracted ${count}`);
todo.splice(todo.indexOf(file), 1);
if (todo.length == 0) {
const anAsObj = {};
for (let k = 0; k < an.length; k++) {
anAsObj[an[k]] = 1;
}
outputStream.write(JSON.stringify(anAsObj));
outputStream.close();
//console.log(an);
console.log(`done, produced: ${outputFile}`);
cb();
}
});
} catch (err) {
console.log(err);
}
})
.on('close', function (): void {
console.log(`${file}: extracted ${count}`);
resolve();
});
} catch (err) {
console.log(err);
reject(err);
}
});
promises.push(promise);
}
Promise.all(promises).then(function () {
if (fs.existsSync(outputFile)) {
fs.unlinkSync(outputFile);
}
const outputStream: fs.WriteStream = fs.createWriteStream(outputFile);
const anAsObj = {};
for (let k = 0; k < an.length; k++) {
anAsObj[an[k]] = 1;
}
outputStream.write(JSON.stringify(anAsObj));
outputStream.close();
//console.log(an);
console.log(`done, produced: ${outputFile}`);
cb();
});
});
}
sonar.projectName=english-a-an-list
sonar.sources=lib
......@@ -5,16 +5,48 @@
"main": "dist/index.js",
"scripts": {
"clean": "rm -rf dist",
"test": "mocha",
"test": "nyc --reporter=lcov --reporter=text mocha",
"build": "tsc"
},
"repository": {
"type": "git",
"url": "[email protected]:rosaenlg-projects/rosaenlg.git"
},
"nyc": {
"extension": [
".ts"
],
"exclude": [
"test/"
],
"check-coverage": true,
"statements": 95,
"lines": 95,
"functions": 95,
"branches": 95,
"watermarks": {
"statements": [
60,
95
],
"lines": [
60,
95
],
"functions": [
60,
95
],
"branches": [
60,
95
]
}
},
"devDependencies": {
"english-a-an-list": "0.6.2",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"typescript": "^3.7.2"
},
"keywords": [
......
sonar.projectName=english-a-an
sonar.sources=lib
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info
......@@ -18,7 +18,7 @@ export function getDet(
}
if (detType === 'POSSESSIVE') {
if (numberOwner != 'P' && (genderOwner != 'M' && genderOwner != 'F' && genderOwner != 'N')) {
if (numberOwner != 'P' && genderOwner != 'M' && genderOwner != 'F' && genderOwner != 'N') {
const err = new Error();
err.name = 'InvalidArgumentError';
err.message = `genderOwner must be F M or N when POSSESSIVE (unless numberOwner is P)`;
......
......@@ -5,7 +5,7 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "nyc mocha",
"test": "nyc --reporter=lcov --reporter=text mocha",
"build": "tsc"
},
"repository": {
......
sonar.projectName=english-determiners
sonar.sources=lib
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.projectName=english-plurals-list
sonar.sources=lib
......@@ -5,7 +5,7 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "nyc mocha",
"test": "nyc --reporter=lcov --reporter=text mocha",
"clean": "rm -rf dist",
"build": "tsc"
},
......
sonar.projectName=english-plurals
sonar.sources=lib
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.projectName=english-verbs-gerunds
sonar.sources=lib
......@@ -5,7 +5,7 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "nyc mocha",
"test": "nyc --reporter=lcov --reporter=text mocha",
"clean": "rm -rf dist",
"build": "tsc"
},
......
sonar.projectName=english-verbs-helper
sonar.sources=lib
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info
......@@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"scripts": {
"clean": "rm -rf dist",
"test": "nyc mocha",
"test": "nyc --reporter=lcov --reporter=text mocha",
"build": "tsc"
},
"repository": {
......
sonar.projectName=french-adjectives
sonar.sources=lib
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info
......@@ -5,7 +5,7 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "nyc mocha",
"test": "nyc --reporter=lcov --reporter=text mocha",
"build": "tsc"
},
"repository": {
......
sonar.projectName=french-determiners
sonar.sources=lib
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info
......@@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"scripts": {
"clean": "rm -rf dist",
"test": "nyc mocha",
"test": "nyc --reporter=lcov --reporter=text mocha",
"build": "tsc && cp resources/CC_BY-SA_3.0.html dist"
},
"repository": {
......
sonar.projectName=french-h-muet-aspire
sonar.sources=lib
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info
......@@ -5,7 +5,7 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "nyc mocha",
"test": "nyc --reporter=lcov --reporter=text mocha",
"build": "tsc"
},
"repository": {
......
sonar.projectName=french-ordinals
sonar.sources=lib
sonar.tests=test
sonar.javascript.lcov.reportPaths=coverage/lcov.info
......@@ -172,7 +172,7 @@ export function processFrenchVerbs(inputFile: string, outputFile: string, cb: Fu
const outputStream: fs.WriteStream = fs.createWriteStream(outputFile);
lineReader
.on('line', function(line: string): void {
.on('line', function (line: string): void {
const lineData: string[] = line.split('\t');
if (lineData[1] === 'v') {
......@@ -181,9 +181,7 @@ export function processFrenchVerbs(inputFile: string, outputFile: string, cb: Fu
const code: string = lineData[3];
let ignore = false;
if (inf === '_error') {
ignore = true;
} else if (inf === 'être' && code === 'P3p' && ff === 'st') {
if (inf === '_error' || (inf === 'être' && code === 'P3p' && ff === 'st')) {
ignore = true;
}
......@@ -212,7 +210,7 @@ export function processFrenchVerbs(inputFile: string, outputFile: string, cb: Fu
}
}
})
.on('close', function(): void {
.on('close', function (): void {
outputStream.write(JSON.stringify(verbsInfo));
console.log(`done, produced: ${outputFile}`);
cb();
......
sonar.projectName=french-verbs-lefff
sonar.sources=lib
sonar.projectName=french-verbs-transitive
sonar.sources=lib
......@@ -319,10 +319,8 @@ export function getConjugation(
const voyelles = 'aeiouyàáâãäåèéêëìíîïòóôõöøùúûüÿAEIOUYÀÁÂÃÄÅÈÉÊËÌÍÎÏÒÓÔÕÖØÙÚÛÜŸ'; // toutesVoyellesMinMaj
const startsWithVoyelle = RegExp(`^[${voyelles}]`);
if (startsWithVoyelle.test(conjugated)) {
contract = true;
} else if (conjugated.startsWith('h') && !isHAspire(verb)) {
// take infinitive, not conjugated form
// ?? take infinitive, not conjugated form
if (startsWithVoyelle.test(conjugated) || (conjugated.startsWith('h') && !isHAspire(verb))) {
contract = true;
}
}
......