mercredi 29 juillet 2015

Inspection of long condition bodies using Intellij Idea

I want to find and re-factor code snippets like this:

@Override
public void init() {
    if (!initialized) {
        super.init();
        setSizeFull();
        initLayout();
        initTable();
        initButtons();
        initialized = true;
    }
}

to

@Override
public void init() {
    if (initialized) {
        return;
    }
    super.init();
    setSizeFull();
    initLayout();
    initTable();
    initButtons();
    initialized = true;
}

I couldn't find any way to find all snippets like this in my code. I've tried regular expression but I can not write a valid regular expression to find them. If there is any solution I would like to hear it. Thanks...

Aucun commentaire:

Enregistrer un commentaire