Skip to content

Commit d76ca3e

Browse files
authored
Merge pull request #320 from sir-gon/develop
[BUGFIX] sonarcloud typescript:S6959 fixed.
2 parents 158239e + 01a433d commit d76ca3e

File tree

4 files changed

+71
-9
lines changed

4 files changed

+71
-9
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Node.js CI Coverage
2+
3+
on:
4+
push:
5+
branches: [ "main", "develop", "feature/*" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
os: [
17+
"ubuntu-latest"
18+
]
19+
node-version: [20.x]
20+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4
25+
26+
- name: Set up Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
31+
- name: Install dependencies
32+
run: npm ci --verbose
33+
34+
- name: Lint
35+
run: npm run lint
36+
37+
- name: Run the tests
38+
run: npm test -- --coverage
39+
40+
- name: Upload coverage reports to Codecov with GitHub Action
41+
uses: codecov/codecov-action@v4
42+
with:
43+
token: ${{ secrets.CODECOV_TOKEN }} # required
44+
verbose: true # optional (default = false)
45+
46+
- name: SonarCloud Scan
47+
uses: SonarSource/sonarcloud-github-action@master
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
50+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/node.js.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Node.js CI
1+
name: Node.js CI Tests
22

33
on:
44
push:
@@ -37,10 +37,4 @@ jobs:
3737
run: npm run lint
3838

3939
- name: Run the tests
40-
run: npm test -- --coverage
41-
42-
- name: Upload coverage reports to Codecov with GitHub Action
43-
uses: codecov/codecov-action@v4
44-
with:
45-
token: ${{ secrets.CODECOV_TOKEN }} # required
46-
verbose: true # optional (default = false)
40+
run: npm test

sonar-project.properties

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
sonar.projectKey=sir-gon_algorithm-exercises-ts
2+
sonar.organization=sir-gon
3+
4+
# This is the name and version displayed in the SonarCloud UI.
5+
#sonar.projectName=algorithm-exercises-ts
6+
#sonar.projectVersion=1.0
7+
8+
9+
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
10+
sonar.sources=src
11+
sonar.exclusions=**/*.json
12+
13+
# Encoding of the source code. Default is default system encoding
14+
sonar.sourceEncoding=UTF-8
15+
16+
# Coverage
17+
sonar.javascript.lcov.reportPaths=./coverage/lcov.info

src/projecteuler/problem0018.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export function problem0018(_triangle: number[][]): number {
3131
console.debug(`leafs count: ${leafs.length}`);
3232
console.debug(`leafs: ${leafs}`);
3333

34-
const max = leafs.reduce((a, b) => (a > b ? a : b));
34+
const __START_FROM__ = 0;
35+
const max = leafs.reduce((a, b) => (a > b ? a : b), __START_FROM__);
3536

3637
return max;
3738
}

0 commit comments

Comments
 (0)