Giter Club home page Giter Club logo

Comments (4)

yupinghu avatar yupinghu commented on June 4, 2024

Namely:

Style and assert/error on default fall-through.

    switch (req.query.action) {
        case 'subscribe': {
            return onSubscribe(req, res, next);
        } break;
        case 'unsubscribe': { 
            return onUnsubscribe(req, res, next);
        } break;
        default: {
            assert(false, 'some descriptive message here');
        } break;
    }

from blpapi-http.

thmiceli avatar thmiceli commented on June 4, 2024

Is the 'break' statement on the same line as the closing curly brace a common pattern? It seems odd to me. It is also deadcode after a return statement, that doesn't bother me as a reader of the code but it may be reported by static analysis tools.

from blpapi-http.

ericvw avatar ericvw commented on June 4, 2024

For background/motivation, the convention ensures that the scope block encompass all statements related to the case. It is arbitrary for the break; to be on the same line as the closing }, but it makes some sense because you really want to end the case for that scope block.

Since break; would be a no-op after a return, should static code analysis tools ignore that?

from blpapi-http.

yupinghu avatar yupinghu commented on June 4, 2024

I think Thierry's point is precisely that the break is unreachable because of the return, hence it'd be reported as dead code by a naive checker. :)

from blpapi-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.