Skip to content

Commit

Permalink
Keep only maint test cases in its
Browse files Browse the repository at this point in the history
  • Loading branch information
yassin-kammoun-sonarsource committed Oct 29, 2019
1 parent 117166a commit e4f4a11
Showing 1 changed file with 0 additions and 102 deletions.
102 changes: 0 additions & 102 deletions its/plugin/projects/ts-rule-project/S4822.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ function singlePromise() {
}
}

function conditionalPromise(cond: boolean) {
try { // Noncompliant
if (cond) {
returningPromise();
} else {
let x = 42;
returningPromise();
}
} catch (e) {
console.log(e);
}
}

async function okWithAwait() {
try {
await returningPromise();
Expand All @@ -31,99 +18,10 @@ async function okWithAwait() {
}
}

function okWithAnotherCall() {
try {
someFunc(); // can throw potentionally
returningPromise();
} catch (e) {
console.log(e);
}
}

function okWithoutCatch() {
try {
returningPromise();
} finally {
console.log("finally");
}
}

async function severalTry() {
try {
await returningPromise();
} catch (e) {
console.log(e);
}

try { // Noncompliant
returningPromise();
} catch (e) {
console.log(e);
}
}

function newPromise() {
try { // Noncompliant
new Promise((res, rej) => {});
} catch (e) {
console.log(e);
}
}

function okWithNestedFunc() {
try {
let func = () => returningPromise();
} catch (e) {
console.log(e);
}
}

function returningPromiseAndThrowing(cond: boolean) {
if (cond) {
return new Promise((res, rej) => {});
} else {
throw "error";
}
}

// can be considered as False Positive as `returningPromiseAndThrowing` can throw
function testFunctionReturningPromiseAndThrowing(cond: boolean) {
try { // Noncompliant
returningPromiseAndThrowing(cond);
} catch (e) {
console.log(e);
}
}

function uselessTry() {
try { // Noncompliant
returningPromise().catch();
} catch (e) {
console.log(e);
}
}

function uselessTryThenCatch() {
try { // Noncompliant
returningPromise().then().catch();
} catch (e) {
console.log(e);
}
}

function onlyOnePromiseWhenChainedPromise() {
try { // Noncompliant
returningPromise().then(() => {});
} catch (e) {
console.log(e);
}
}

async function okWithAwaitAndPromise() {
try {
await returningPromise(); // this can throw
returningPromise();
} catch (e) {
console.log(e);
}
}

0 comments on commit e4f4a11

Please sign in to comment.