File oauth_server.js
has 292 lines of code (exceeds 250 allowed). Consider refactoring. Open
import bodyParser from 'body-parser';
OAuth = {};
OAuthTest = {};
Function middleware
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
const middleware = async (req, res, next) => {
let requestData;
// Make sure to catch any exceptions because otherwise we'd crash
// the runner
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function middleware
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
const middleware = async (req, res, next) => {
let requestData;
// Make sure to catch any exceptions because otherwise we'd crash
// the runner
Function _endOfLoginResponse
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
OAuth._endOfLoginResponse = (res, details) => {
res.writeHead(200, {'Content-Type': 'text/html'});
let redirectUrl;
if (details.loginStyle === 'redirect') {
Function renderEndOfLoginResponse
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const renderEndOfLoginResponse = options => {
// It would be nice to use Blaze here, but it's a little tricky
// because our mustaches would be inside a <script> tag, and Blaze
// would treat the <script> tag contents as text (e.g. encode '&' as
// '&'). So we just do a simple replace.
Function _renderOauthResults
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
OAuth._renderOauthResults = (res, query, credentialSecret) => {
// For tests, we support the `only_credential_secret_for_test`
// parameter, which just returns the credential secret without any
// surrounding HTML. (The test needs to be able to easily grab the
// secret and use it to log in.)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _endOfLoginResponse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
OAuth._endOfLoginResponse = (res, details) => {
res.writeHead(200, {'Content-Type': 'text/html'});
let redirectUrl;
if (details.loginStyle === 'redirect') {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function renderEndOfLoginResponse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const renderEndOfLoginResponse = options => {
// It would be nice to use Blaze here, but it's a little tricky
// because our mustaches would be inside a <script> tag, and Blaze
// would treat the <script> tag contents as text (e.g. encode '&' as
// '&'). So we just do a simple replace.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"