Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jihye1 patch 1 #11

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions 20270830.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function say(msg) {
return (() => {
console.log(msg);
return 'Done';
});
}
function doSomethingAfter1Sec(something) {
setTimeout(() => {
something();
}, 1000);
}
async function asyncCall() {
console.log('Start');
var result = await doSomethingAfter1Sec(say('Hi')); // AWAIT_NON_PROMISE alarm because 'doSomethingAfter1Sec(...)' is not Promise.
console.log('Result: ' + result);
console.log('End');

console.log('Start');
await [1, 2, 3].map(x => doSomethingAfter1Sec(say(x))); // AWAIT_NON_PROMISE alarm because awaiting an array has no effect.
console.log('End');
}
16 changes: 1 addition & 15 deletions cwe.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
// This will show examples related with the Common Weakness Enumeration (CWE).

function CWE_398() { // IDENTICAL_BRANCHES
if (x >= 0) {
y = x;
} else {
y = x;
}
}

function CWE_476() { // NULL_POINTER
var obj;
var y = obj.x;
console.log(y);
}

function CWE_480() { // BAD_BITWISE_OPERATOR
var obj = null;
if (obj & obj.prop) {
Expand Down Expand Up @@ -60,7 +46,7 @@
}

function CWE_670(x) { // STRAY_SEMICOLON
while (++x <= 10) ;
while (++x <= 100)
{
sum += x;
}
Expand Down
12 changes: 12 additions & 0 deletions cwe/cwe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function CWE_398() { // IDENTICAL_BRANCHES
if (x >= 0) {
y = x;
} else {
y = x;
}
}
function CWE_476() { // NULL_POINTER
var obj;
var y = obj.x; // UNINITIALIZED_LOCAL_VAR
console.log(y);
}
22 changes: 22 additions & 0 deletions react-rule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const instance = ReactDOM.render(<App />, rootElement);
foo(instance); // ASYNC_RENDER_RETURN_VALUE alarm

import ReactDOM from 'react-dom';

ReactDOM.render(
<div dangerouslySetInnerHTML={{ __html: "myHTML" }}>
<Children /> {/* BAD_DANGER_WITH_CHILDREN alarm */}
</div>, document.getElementById("root")
);

import React from 'react';

class Hello extends React.Component {
render() {
return (
<div onClick="console.log('clicked')"> {/* BAD_EVENT_HANDLER alarm */}
Hello
</div>
);
}
}