Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Claudius Link
Claudius Link
@realn2s@infosec.exchange  ·  activity timestamp 2 weeks ago

As my company is evaluation the use of #Cursor I'm playing around with it. First expression is mixed.

Scratching my own itch, I thought of implementing a software tool which checks which books of a #HumbleBundle book bundle I already own. Initially again my HumbleBundle library and additionally against my #BookWyrm.

I started in the planning mode.

Cursor listed some steps on how to accomplish the task and asked me which language I would like to use.

Stating that I would use whatever is best suited, Cursor picked #Python.

Being cheeky and with my preferred use in mind I asked if a browser plugin wouldn't be better suited
(imagine that, looking at a bundle, the books you own are automatically highlighted)

No chance. Cursor was determined to stick with Python!

Ok, lets generate the project

1/n

#VibeCoding

  • Copy link
  • Flag this post
  • Block
Claudius Link
Claudius Link
@realn2s@infosec.exchange replied  ·  activity timestamp 2 weeks ago

#Cursor generate roughly 1k lines of Python.
This included the (pseudo) code for querying #Bookwyrm. I would have preferred to generate this later (as a second step) But maybe it my mistake. I was prompting it wrong. I shouldn't have mentioned anything I didn't directly want.

Without looking at the Bookwyrm client code in detail, I doubt that it will work as my instance ( @realn2s@bookwyrm.social) require #2fa 🤷🏻

Checking the HumbleBundle client code I noticed several things

It contained a ton of normalization code. Of which I'm not sure if it is necessary (it might as well be, but I would leave it out for now. As it much harder to figure out that code isn't required but get executed nevertheless, than noticing that code is missing)

The authentication was done through a session cookie you had to extract form the browser. Cursor proposed to write it to an env file (that doesn't feel terrible secure 😬)

The Humble bundle client could either get the session cookie passed, or it would query the env 😬. I don't consider this good programming practice.

The code looks like it handles HumbleBundle games as well. This was requested and is additional code which shouldn't be there.

Reading through the code it looked about right. But it was too mich code, too much gold plating for me to be confident that the code really would be working.

Cursor provided no way to test the code apart from running it. And I'm not going to run it with my understanding.

On the positive side
I learned about the Click command line option "parsing" library

and about the dataclass decorator in #Python

Next step, let's try if Cursor can iteratively fixe some of my "issues"

2/n

  • Copy link
  • Flag this comment
  • Block
Claudius Link
Claudius Link
@realn2s@infosec.exchange replied  ·  activity timestamp 2 weeks ago

@realn2s@bookwyrm.social

@realn2s@bookwyrm.social

The #Cursor prompt:

Remove the Bookwyrm code for now

removed nearly 300 lines of code and touched every file 😱

Removing "unnecessary" only deleted 6 lines (so the problem maybe wasn't as bad as I initially thought)

Remove all "game" related code surprisingly added on LOC, a comment.
But funny enough it made the code far clearer to understand. Where previously "gamekeys" were used now it was "order_keys". Additionally, the comment that the get_gamekeys() method returns all order keys was added (not sure if this is true)

Sidenote: Switching the variable naming to suddenly use an '_' is a bit strange.

OK let's try one more thing before wrapping up this experiment and start over with smaller steps.

Let's try to add UnitTests!

3/n

#VibeCoding

  • Copy link
  • Flag this comment
  • Block
Claudius Link
Claudius Link
@realn2s@infosec.exchange replied  ·  activity timestamp 2 weeks ago

@realn2s@bookwyrm.social

I asked #Cursor to generate unit tests for the project.
The result? Does it spark joy (or confidence)?
😬

Again, not really 😕

Nope, that is not a good unit test. This test check the setting of an internal property. This should actually be an implementation detail.

Screenshot of an unit test, basically testing the setting of an internal property
Whole code:

 def test_init_with_cookie(self):
        """Test initialization with session cookie."""
        client = HumbleBundleClient(session_cookie="test_cookie")
        assert client.session_cookie == "test_cookie"
        assert client.session is not None
Screenshot of an unit test, basically testing the setting of an internal property Whole code: def test_init_with_cookie(self): """Test initialization with session cookie.""" client = HumbleBundleClient(session_cookie="test_cookie") assert client.session_cookie == "test_cookie" assert client.session is not None
Screenshot of an unit test, basically testing the setting of an internal property Whole code: def test_init_with_cookie(self): """Test initialization with session cookie.""" client = HumbleBundleClient(session_cookie="test_cookie") assert client.session_cookie == "test_cookie" assert client.session is not None
  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1-alpha.40 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct