void-linux / xbps

The X Binary Package System (XBPS)
https://voidlinux.org/xbps/
Other
821 stars 124 forks source link

Code style changes #276

Open ericonr opened 4 years ago

ericonr commented 4 years ago

So, following @Duncaen suggestions, I'm taking a look at the code for xbps-query, to start off.

        { "revdeps", required_argument, NULL, 'X' },
        { "regex", no_argument, NULL, 0 },
        { "fulldeptree", no_argument, NULL, 1 },
        { "cat", required_argument, NULL, 2 },

I noticed that a few portions of the code, for example xbps-query's main.c, are using raw ints instead of enums for some things. I feel like changing some of those to enums would make the code clearer and the process of messing with it less error prone. So, while possibly adding new features, I could also change some of those raw ints to enums.

Would there be any issue with this?

the-maldridge commented 4 years ago

I like this idea, but I'd like to see it come with test cases to validate behavior before and after. Ideally you'd do it as:

As you mentioned, raw ints are error proned, so care should be taken to not make the problem any worse than it already is.

ericonr commented 4 years ago

Fair enough. It seems XBPS has mainly integration tests instead of unit tests, so I will have to think about how to build them.