Code Monkey home page Code Monkey logo

Comments (8)

vanniktech avatar vanniktech commented on May 24, 2024 1

I've got some own lint rules - https://github.com/vanniktech/lint-rules - the setup is pretty basic and straightforward. Happy to answer any questions. Also have a look at the tests to see how you can test your rule easily without having to build your checks and run them on a real project.

from thirtyinch.

passsy avatar passsy commented on May 24, 2024

Yeah that would be a great addition. This lint check could check if provideView() is overriden, if not it should check if the Activity/Fragment implements the View interface.

I must admit I have no idea how to write custom lint rule and bundle it within the aar.

from thirtyinch.

passsy avatar passsy commented on May 24, 2024

For inspirations see timber lint checks

//cc @winterDroid @vanniktech

from thirtyinch.

winterDroid avatar winterDroid commented on May 24, 2024

Can you provide some more information what issues should be found? I'm not really familiar with this library

from thirtyinch.

vanniktech avatar vanniktech commented on May 24, 2024

Why was I cc'd into this?

from thirtyinch.

passsy avatar passsy commented on May 24, 2024

@vanniktech You're familiar with lint and maybe interested in contributing 😉, ignore otherwise

@winterDroid This is the minimal setup when using a TiActivity

// Lint warning because MyActivity doesn't implement MyView 
public class MyActivity extends TiActivity<MyPresenter, MyView> {

    @Override
    public MyPresenter createPresenter() {
        return new MyPresenter();
    }
}

public class MyPresenter extends TiPresenter<MyView> {
    // boilerplate
}

interface MyView extends TiView {
    // boilerplate
}

It compiles fine but crashes at runtime because MyActivity doesn't implement MyView. Lint should warn here.

Correct MyActivity implementation:

// No warning, MyActivity implements MyView
public class MyActivity extends TiActivity<MyPresenter, MyView> implements MyView {

    @Override
    public MyPresenter createPresenter() {
        return new MyPresenter();
    }
}

But lint should not warn when the user has overridden provideView()

public class MyActivity extends TiActivity<MyPresenter, MyView> {

    @Override
    public MyPresenter createPresenter() {
        return new MyPresenter();
    }

    @Override
    public MyView provideView() {
        // provideView implemented, no warning required that MyActivity doesn't implement MyView
        return new MyView() { };
    }
}

from thirtyinch.

StefMa avatar StefMa commented on May 24, 2024

I am just going to leave that here “Writing your first Lint check” @vanniktech https://medium.com/@vanniktech/writing-your-first-lint-check-39ad0e90b9e6

from thirtyinch.

vanniktech avatar vanniktech commented on May 24, 2024

Ping me when you've got your first check for a review.

from thirtyinch.

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.