lazehang/accelerateCrypto-backend

View on GitHub

Showing 4 of 24 total issues

Function exports has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (app) => {

    console.log("passport init");
    app.use(passport.initialize());
    console.log("passport session");
Severity: Major
Found in passport.ts - About 2 hrs to fix

    Function register has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async register(username: string, name: string, password: string, isAdmin: boolean) {
            return new Promise( (resolve, reject) => {
                this.knex('users').where({ username: username }).first()
                    .then((user) => {
                        if (user) {
    Severity: Minor
    Found in services/UserService.ts - About 1 hr to fix

      Function storeHistory has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          storeHistory(coinId: number, price: string) {
              this.knex('coin_history').select('*').where('coin_id', '=', coinId).then((row) => {
                  let prices;
                  if (row.length > 0) {
                      const last_updated = row[0].updated_at;
      Severity: Minor
      Found in services/CoinService.ts - About 1 hr to fix

        Function hashPassword has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports.hashPassword = (plainTextPassword: string) => {
            return new Promise((resolve, reject) => {
                bcrypt.genSalt((err, salt) => {
                    if (err) {
                        reject(err);
        Severity: Minor
        Found in util/bcrypt.ts - About 35 mins to fix

        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

        Severity
        Category
        Status
        Source
        Language