Skip to main content

CodeSOD: Lint Brush Off

22 hours 22 minutes ago

A few years back, C# added the concept of "primary constructors". Instead of declaring the storage for class members and then initializing them in the constructor, you can annotate the class itself with the required fields, and C# automatically generates a constructor for you. It's all very TypeScript and very Microsoft, and certainly cuts down on some boilerplate.

Esben B's team isn't really using them in many places, but they are using a linter which is opinionated about them. So this in-line constructor causes the linter to complain:

public DocumentNetworkController(ILookupClient service)

The linter wants you to switch this to a primary constructor. Esben didn't want to do that, and didn't want to change the global linter configuration, and so added a pragma to disable that particular warning:

#pragma warning disable IDE0290 // Use primary constructor public DocumentNetworkController(ILookupClient service) #pragma warning restore IDE0290

The linter didn't like this. It threw a new warning: that this suppression wasn't needed. Which was news to Esben, as clearly the suppression was needed if you wanted to make the warnings go away. The obvious solution was to disable the warning that you didn't need to disable the warning:

#pragma warning disable IDE0079, IDE0290 // Use primary constructor public DocumentNetworkController(ILookupClient service) #pragma warning restore IDE0290, IDE0079

Except this doesn't work. These pragmas take effect on the next line, which means you can't disable IDE0079 on the same line as IDE0290 and expect it to work. Which means the final version of the code looked like this:

#pragma warning disable IDE0079 // Disable warning about not needed supression #pragma warning disable IDE0290 // Use primary constructor public DocumentNetworkController(ILookupClient service) #pragma warning restore IDE0290, IDE0079

Esben writes:

So the nice recommendation to use a primary ctor ended up with 3 lines of annoying boilerplate code. Good times \o/

While yes, this is frustrating, I will say there's an element of "when the table saw keeps taking fingers off, that may be more of a you problem." I don't know the details, so I can't say, "just change the linter config or adopt its recommendation" and claim that the problem goes away, but when the tool hurts you, it's a definite sign of one of two things: it's either the wrong tool, or you're using it wrong.

[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.
Remy Porter

Elon Musk and OpenAI CEO Sam Altman Head To Court

1 day 1 hour ago
An anonymous reader quotes a report from the Associated Press: Technology tycoons Elon Musk and Sam Altman are poised to face off in a high-stakes trial revolving around the alleged betrayal, deceit and unbridled ambition that blurred the bickering billionaires' once-shared vision for the development of artificial intelligence. The trial, which started Monday with jury selection, centers on the 2015 birth of ChatGPT maker OpenAI as a nonprofit startup primarily funded by Musk before evolving into a capitalistic venture now valued at $852 billion. The trial's outcome could sway the balance of power in AI -- breakthrough technology that is increasingly being feared as a potential job killer and an existential threat to humanity's survival. Those perceived risks are among the reasons that Musk, the world's richest person, cites for filing an August 2024 lawsuit that will now be decided by a jury and U.S. District Judge Yvonne Gonzalez Rogers in Oakland, California. The civil lawsuit accuses Altman, OpenAI's CEO, and his top lieutenant, Greg Brockman, of double-crossing Musk by straying from the San Francisco company's founding mission to be an altruistic steward of a revolutionary technology. The lawsuit alleges they shifted into a moneymaking mode behind his back. OpenAI has brushed off Musk's allegations as an unfounded case of sour grapes that's aimed at undercutting its rapid growth and bolstering Musk's own xAI, which he launched in 2023 as a competitor. Gonzalez Rogers questioned potential jurors Monday about their views on Musk, Altman and artificial intelligence. Some jurors said they had negative views of Musk, but most said they would still be able to treat him fairly and focus on the facts of the case. [...] "Part of this is about whether a jury believes the people who will testify and whether they are credible," Gonzalez Rogers said during a court hearing earlier this year while explaining why she believe the case merited a trial. The judge will make the final decision on the case, with the jury serving in an advisory role. The latest development is that a jury has been seated. During selection, several prospective jurors expressed negative views of Elon Musk, but Judge Yvonne Gonzalez Rogers rejected attempts by Musk's lawyer to remove some of them solely on that basis, saying dislike of Musk does not automatically mean someone can't be fair. The court is selecting nine jurors, and the case is expected to wrap by May 21, when it would go to the jury. Tomorrow, April 28th, will feature opening statements.

Read more of this story at Slashdot.

BeauHD