-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup items.cpp #1967
Cleanup items.cpp #1967
Conversation
7e8bd56
to
bc9d3b8
Compare
I'll tick stuff that I've proofed/tested. Feel free to join.
|
The vendors' inventories are now sorted using std::sort. The items are sorted by item type, so this change of algorithm may produce a slightly different item order from vanilla. |
Cleanup SpawnMapOfDoom, SpawnRuneBomb, SpawnTheodore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but there where a couple of notes mostly related to code style.
Looks like the test is failing, several items are morphing. Do you need any help with getting feedback from the test? |
Please do. Or better yet, tell me how to run the tests myself. (I set RUN_TESTS to ON in CMakeLists.txt, but that apparently didn't do anything.) |
If you are on linux or WSL: apt-get install -y cmake curl g++ git lcov libgtest-dev libfmt-dev libsdl2-dev libsdl2-ttf-dev libsodium-dev
cmake .. -DRUN_TESTS=ON
make -j 4
./devilutionx I usually create a I don't know what would be needed to do it on VC or Mac |
Looks like you found the issue 👍 Did you also manage to get the tests running? What system are you developing on? |
Yes, it was a mechanical error in RndVendorItem. "-DRUN_TESTS=ON" did the trick. I'm working on Linux. |
Co-authored-by: Anders Jenbo <[email protected]>
50 commits on a single PR seems excessive to me, and the fact that each commit is just "Cleanup X" is really, really bad imho. We should be specific on what we are doing, like "Use Point struct for X/Y/Z" instead of "Cleanup". |
I guess I'll open 50 PRs next time :) I frankly expect this to get squashed. I agree that the commits that did make a function use Point could have been worded differently, but it's a current policy to use Point wherever possible, so I'd count that as cleanup. Aside from that, all other Cleanup Foo commits were literally nothing more than cleanups of Foo, no matter how you slice it. |
Oh, guess I don't have to bother with any rebasing then 👍 |
@vlolteanu you got an achievement: The code now lives up to 3/10 out of ISO 25010 specifications for maintainable code. |
Haha that was unexpected. If I understand that correctly, this PR pushed devilutionX over the edge into 3/10, right? |
Correct, you removed the last 21 lines of duplication for us to hit 95% unique code. When we forked from Devilution it was at 89% |
The next mile stone is a lot further in to the future. Most likely it would be reducing the amount of code in functions with many parameters. This clean up did make a small jump on that graph as well, with some code in the 5-6 parameters tier dropping to 3-4 instead, probably due to Splitting up long functions (like what I did for I don't know ho much access you guys have to the list, but if you like I can generate issues for some of the functions that are listed as prime candidates for refactoring. Here's an examples of an issue generated for the 4 basic categories. There are also more advanced lists relating to code coupling. Dealing with that is usually much more complicated and it also tends to get worse as we work on the basic issues and code sharing inevitably leads to more coupling. In my experience dealing with this comes much later when the general issues are mostly death with and you can better start to reason about application structure. |
Marking it as draft for the moment.
The changes were all mechanical, and hence, error-prone when all done at once. An extra pair of eyes would be really needed here.