News for hackers. Stuff that matters.
Re:Amazon CodeGuru – Preview by ReidZB on Tuesday December 03, 2019 @02:19PM (#21695618)
The code review feature seems too expensive to run on every PR automatically (to me): $0.75 per 100 lines of code. From their example pricing: "if you have a typical pull request with 500 lines of code, it would only cost $3.75 to run CodeGuru Reviewer on it." I wonder if it's actually good enough to justify that price.
Re:Amazon CodeGuru – Preview by femto113 on Tuesday December 03, 2019 @03:47PM (#21696536)
If it’s trained on software written by Amazon it’s probably worth the $3.75 just so you can do the exact opposite of what they recommend.
Re:Amazon CodeGuru – Preview by danpalmer on Tuesday December 03, 2019 @04:44PM (#21697065)
I don’t have much context, but I’ve never seen Amazon as a technical leader in the industry. They’re absolutely a business leader, and the services they provide can be good, but at a code level I’ve always thought of them as very MVP, if it works it’s good enough.

For code review services I’d expect a level far above this. Maybe they are able to do that, but I don’t have any existing positive bias towards this, and a few things against it.

Re:Amazon CodeGuru – Preview by JaRail on Tuesday December 03, 2019 @10:31PM (#21699356)
It'll probably generate irrelevant stats on the engineers to send directly to their managers to use against them in their next review.
Re:Amazon CodeGuru – Preview by areactnativedev on Wednesday December 04, 2019 @05:34AM (#21701087)
You have no idea how much this resonated ^^

Just needded to add an AWS library in my code base and BAM! here is how my console will look on every reload from now on :

:8081/index.bundle?platform=ios&dev=true&minify=false:93 Require cycle: node_modules/aws-sdk/lib/react-native-loader.js -> node_modules/aws-sdk/lib/credentials/temporary_credentials.js -> node_modules/aws-sdk/clients/sts.js -> node_modules/aws-sdk/lib/react-native-loader.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. metroRequire @ :8081/index.bundle?platform=ios&dev=true&minify=false:93 :8081/index.bundle?platform=ios&dev=true&minify=false:93 Require cycle: node_modules/aws-sdk/lib/react-native-loader.js -> node_modules/aws-sdk/lib/credentials/cognito_identity_credentials.js -> node_modules/aws-sdk/clients/cognitoidentity.js -> node_modules/aws-sdk/lib/react-native-loader.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. metroRequire @ :8081/index.bundle?platform=ios&dev=true&minify=false:93 :8081/index.bundle?platform=ios&dev=true&minify=false:28851 Warning: AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-community/async-storage' instead of 'react-native'. See https://github.com/react-native-community/react-native-async... reactConsoleErrorHandler @ :8081/index.bundle?platform=ios&dev=true&minify=false:28851 :8081/index.bundle?platform=ios&dev=true&minify=false:93 Require cycle: node_modules/@aws-amplify/analytics/lib/Providers/index.js -> node_modules/@aws-amplify/analytics/lib/Providers/AWSKinesisFirehoseProvider.js -> node_modules/@aws-amplify/analytics/lib/Providers/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. metroRequire @ :8081/index.bundle?platform=ios&dev=true&minify=false:93 :8081/index.bundle?platform=ios&dev=true&minify=false:93 Require cycle: node_modules/@aws-amplify/predictions/lib/types/Providers/AbstractConvertPredictionsProvider.js -> node_modules/@aws-amplify/predictions/lib/types/Providers/index.js -> node_modules/@aws-amplify/predictions/lib/types/Providers/AbstractConvertPredictionsProvider.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. metroRequire @ :8081/index.bundle?platform=ios&dev=true&minify=false:93 :8081/index.bundle?platform=ios&dev=true&minify=false:93 Require cycle: node_modules/@aws-amplify/predictions/lib/types/Providers/index.js -> node_modules/@aws-amplify/predictions/lib/types/Providers/AbstractIdentifyPredictionsProvider.js -> node_modules/@aws-amplify/predictions/lib/types/Providers/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. metroRequire @ :8081/index.bundle?platform=ios&dev=true&minify=false:93 :8081/index.bundle?platform=ios&dev=true&minify=false:93 Require cycle: node_modules/@aws-amplify/predictions/lib/types/Providers/index.js -> node_modules/@aws-amplify/predictions/lib/types/Providers/AbstractInterpretPredictionsProvider.js -> node_modules/@aws-amplify/predictions/lib/types/Providers/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. metroRequire @ :8081/index.bundle?platform=ios&dev=true&minify=false:93 :8081/index.bundle?platform=ios&dev=true&minify=false:93 Require cycle: node_modules/@aws-amplify/predictions/lib/Providers/index.js -> node_modules/@aws-amplify/predictions/lib/Providers/AmazonAIPredictionsProvider.js -> node_modules/@aws-amplify/predictions/lib/Providers/index.js

[dead]
Re:Amazon CodeGuru – Preview by heyoni on Tuesday December 03, 2019 @08:17PM (#21698728)
Definitely no bias there ;P
Re:Amazon CodeGuru – Preview by auslegung on Tuesday December 03, 2019 @02:27PM (#21695734)
That’s incredibly cheap, assuming it provides good suggestions. How much time does it take you to review 500 lines of code change, and what’s your time worth? If it takes 10 minutes and your time is worth about $20/hour or more, this service will part for itself immediately.
Re:Amazon CodeGuru – Preview by EpicEng on Tuesday December 03, 2019 @03:13PM (#21696206)
Our code reviews are far more "is this the right way to solve the problem?" than "hey, you never use that variable you declared." The latter would be picked up by our linter; I'm having a hard time seeing the value proposition here.

>It’s like having a distinguished engineer on call, 24x7

I don't believe that, regardless of how many times they sprinkle in the words "machine" and "learning".

Re:Amazon CodeGuru – Preview by dickjocke on Tuesday December 03, 2019 @03:48PM (#21696548)
I'd be very surprised if the service they've announced is a linter.

The announcement says it can even analyze parts your code that are more computationally expensive than they need to be. I'm not sure I understand the skepticism--surely they have among the largest code repositories in the world. Why couldn't they train models on it to look at best practices and even compare code practices to different metrics.

Re:Amazon CodeGuru – Preview by ShamelessC on Tuesday December 03, 2019 @04:03PM (#21696681)
Isn't this just calculating the cyclomatic complexity?
Re:Amazon CodeGuru – Preview by ralmeida on Tuesday December 03, 2019 @04:42PM (#21697040)
No - OP meant computationally expensive, not cognitively expensive. Two nested for-loops can be O(nˆ2) but can have a cyclomatic complexity as low as 1.
Re:Amazon CodeGuru – Preview by ehsankia on Tuesday December 03, 2019 @03:55PM (#21696615)
It may not be as good as a human, but I highly doubt it's a linter either. It's somewhere in between. If their claims are true, and it has been trained on hundreds of thousands of their own reviews, the AI could have picked up common patterns that are beyond lint but still real mistake a good reviewer would spot.
Re:Amazon CodeGuru – Preview by ReidZB on Tuesday December 03, 2019 @02:55PM (#21696030)
I agree 100%: if it provides good enough suggestions, it could pay for itself pretty easily on regular day-to-day PRs. (Although: not all 500 line PRs are made equal.)

My original comment was definitely unclear. I actually had two separate thoughts (that I didn't communicate well at all):

(1) if your team has occasional large, automated PRs (code generation, automated refactors, etc), you probably don't want to run this tool on them because of cost, so anyone that has these large PRs and uses CodeGuru probably needs to build a way into their automation to suppress CodeGuru (or build a way to invoke it for specific PRs)

(2) I also wonder if it's good enough to justify the price on regular PRs

We don't have many situation (1) PRs where I work now, but they do come up occasionally. For example, I've used IntelliJ IDEA's structural find-and-replace to do very large automated refactors where CodeGuru would be very expensive and probably provide little value. We also do check in some generated code (we usually don't do this, but there are a couple exceptions where we weighed the tradeoffs and decided checking in the generated code was a better solution, in our eyes).

Re:Amazon CodeGuru – Preview by wpietri on Tuesday December 03, 2019 @03:48PM (#21696538)
Only if CodeGuru gets a lot of the value of a code review. But I think finding actual bugs is a pretty small of it.

A good code base is a team-created intellectual work. For that to happen, you need a ton of collaboration, shared learning, evolution of norms, interpersonal bonding, and practice of key social behaviors (e.g., principled negotiation, giving good feedback, recognizing and rewarding good actions). Automated code review gets at none of that.

Re:Amazon CodeGuru – Preview by dajohnson89 on Tuesday December 03, 2019 @02:29PM (#21695753)
You seem to assume that the code review tool can do everything that a human code reviewer can.
Re:Amazon CodeGuru – Preview by kerpele on Tuesday December 03, 2019 @02:40PM (#21695856)
On the other hand, a machine will not get tired or bored where a human most definitely will if the diff is anywhere near that 500 lines
Re:Amazon CodeGuru – Preview by scriptkiddy on Tuesday December 03, 2019 @07:37PM (#21698495)
I disagree. I regularly review PRs with more than 500 changed lines/20+ changed files. I read every single line. I put the same amount of effort into reviewing code as I do writing it; every software engineer should.
Re:Amazon CodeGuru – Preview by mc3 on Tuesday December 03, 2019 @09:50PM (#21699183)
You don't replace the human code review. You supplement it. An AI that can replace the code review would need to be an AGI that "sat" down with your team and understood the architectures and meaning in your code. If it can't say "WTF?" it can't do a full code review.
Re:Amazon CodeGuru – Preview by thayne on Tuesday December 03, 2019 @03:11PM (#21696197)
Although this could certainly supplement a human reviewer, I don't think it could replace one.
Re:Amazon CodeGuru – Preview by takeda on Wednesday December 04, 2019 @01:42AM (#21700129)
You really believe this will free you from traditional code reviews? I would treat it as an advanced linter, and from the pictures looks like that's how it integrates itself in github.
Re:Amazon CodeGuru – Preview by tempsolution on Tuesday December 03, 2019 @03:31PM (#21696379)
Yeah or looking at it the other way around. If this would replace your human reviewer, then maybe you would do good to have some serious discussions with your HR department...
Re:Amazon CodeGuru – Preview by Eclyps on Tuesday December 03, 2019 @03:18PM (#21696254)
Don't accidentally commit `node_modules` - that'd be a costly mistake!
Re:Amazon CodeGuru – Preview by james_s_tayler on Tuesday December 03, 2019 @03:27PM (#21696332)
Or a 35,000 line XML configuration file.
Re:Amazon CodeGuru – Preview by ehsankia on Tuesday December 03, 2019 @03:54PM (#21696597)
Now that I think of it, if it's paid by lines of code, it perversely incentives people to minimize the lines of code, no? Does it count white space and comments? Can I minify my code before passing it to this, then unminify it?
Re:Amazon CodeGuru – Preview by bryanrasmussen on Tuesday December 03, 2019 @04:02PM (#21696674)
Many languages can have code written in them minimized down to a single line. I guess they must have a character count number equals a line qualifier somewhere.
Re:Amazon CodeGuru – Preview by ehsankia on Wednesday December 04, 2019 @01:05PM (#21704927)
But even then, still pushes people to shorten variable names and other kind of minification.
Re:Amazon CodeGuru – Preview by stefano on Tuesday December 03, 2019 @04:15PM (#21696789)
Can you just remove newlines from files? In most languages they're optional.
Re:Amazon CodeGuru – Preview by earenndil on Wednesday December 04, 2019 @02:26AM (#21700285)
Count semicolons then.
Re:Amazon CodeGuru – Preview by takeda on Wednesday December 04, 2019 @01:50AM (#21700153)
If it is as smart as some people here think it would probably output: "are you f#$king with me?"
Re:Amazon CodeGuru – Preview by dizzy3gg on Tuesday December 03, 2019 @04:47PM (#21697105)
Maybe it’s on recommended line formatting
Re:Amazon CodeGuru – Preview by philshem on Tuesday December 03, 2019 @02:43PM (#21695892)
“Time to hire some code golfers, we’ll put the whole app into one line of code.”
Re:Amazon CodeGuru – Preview by skykooler on Tuesday December 03, 2019 @03:44PM (#21696501)
"CodeGuru says this should be separated into more lines..."
Re:Amazon CodeGuru – Preview by bowmessage on Tuesday December 03, 2019 @03:58PM (#21696636)
Really though, why charge by-the-line on this kind of product? Imagine if CodeCommit or Lambda charged you by the line too!
Re:Amazon CodeGuru – Preview by mitchty on Tuesday December 03, 2019 @02:48PM (#21695944)
Nightmares in perl...
Re:Amazon CodeGuru – Preview by Aeolun on Tuesday December 03, 2019 @02:59PM (#21696079)
That sounds pretty terrible to be honest. I cannot imagine getting that kind of value out of it (that I would not get with a simple linter).
Re:Amazon CodeGuru – Preview by Nican on Tuesday December 03, 2019 @02:24PM (#21695672)
I was thinking about the same thing. Even for a small project of 3 developers, it seems like this would rise easily to the $100+/month, for suggestions that may not even be that useful.
Re:Amazon CodeGuru – Preview by rstupek on Tuesday December 03, 2019 @02:43PM (#21695891)
at which point you'd stop paying for it I would imagine?
Re:Amazon CodeGuru – Preview by jtcruthers on Tuesday December 03, 2019 @03:29PM (#21696353)
There doesn't seem to be a point to start paying for it, and the time to stop paying for it seems mighty early
Re:Amazon CodeGuru – Preview by m0zg on Tuesday December 03, 2019 @03:55PM (#21696610)
PR I sent yesterday, line changes: +2,703 −3,529. That's like 50 bucks just for that PR.
Re:Amazon CodeGuru – Preview by perlgeek on Wednesday December 04, 2019 @07:08AM (#21701484)
If another developer reviewed your code, how much time it would it take them, and how much is that time worth?

If you divide the 50 bucks by that number, you get a cost ratio. If it's lower than the ratio of (benefit expected by automatic code review) / (benefit expected by manual code review), it's worth using.

I guess we can speculate all we want; in the end, only experience will show if the service is worth it or not.

Re:Amazon CodeGuru – Preview by aledalgrande on Tuesday December 03, 2019 @07:33PM (#21698472)
dude I hope that was the result of updating yarn.lock or similar, otherwise good luck to your reviewer!
Re:Amazon CodeGuru – Preview by m0zg on Tuesday December 03, 2019 @07:43PM (#21698533)
Nope, it's mostly code. It's a gnarly PR that atomically delivers a feature (and removes the feature that the new one replaces), but this looks about right for my weekly productivity overall, except I usually submit it in smaller PRs, and the delta is mostly lines added.
Re:Amazon CodeGuru – Preview by tkahnoski on Tuesday December 03, 2019 @03:06PM (#21696151)
Trying to compare it to another code analyzer... https://sonarcloud.io/about/pricing 100k lines for €10/mo.
Re:Amazon CodeGuru – Preview by stingraycharles on Tuesday December 03, 2019 @03:15PM (#21696223)
Is that all code or just the diff, though? 100k lines of code in diffs seems like a lot, all code - not so much.
Re:Amazon CodeGuru – Preview by notjustanymike on Tuesday December 03, 2019 @03:46PM (#21696528)
Or when a junior dev switches from tabs to spaces
Re:Amazon CodeGuru – Preview by nivenhuh on Tuesday December 03, 2019 @10:55PM (#21699442)
Or when a junior dev switches from spaces to tabs ;)
Re:Amazon CodeGuru – Preview by billman on Tuesday December 03, 2019 @05:13PM (#21697389)
heh.. I wish it were only junior devs.
Re:Amazon CodeGuru – Preview by spyspy on Tuesday December 03, 2019 @02:24PM (#21695677)
that's insanely expensive if you're doing any type of code generation.
Re:Amazon CodeGuru – Preview by pc86 on Tuesday December 03, 2019 @02:27PM (#21695728)
This seems like a good incentive not to be generating thousands of lines of codes with each PR, which most would probably consider a feature as opposed to a bug.
Re:Amazon CodeGuru – Preview by Someone1234 on Tuesday December 03, 2019 @02:56PM (#21696047)
If you split the same number of lines over two, three, ten, etc PRs it still costs the same. If anything it is incentivising code-golf via line minimization.
Re:Amazon CodeGuru – Preview by derision on Tuesday December 03, 2019 @02:27PM (#21695739)
exactly. IMO if you're generating code, it should happen at build/compile time not at checkin
Re:Amazon CodeGuru – Preview by bentcorner on Tuesday December 03, 2019 @10:43PM (#21699396)
I'm not a fan of this. My team does this a lot and invariably it leads to having stuff be unfindable because the source you really want is in your build directory and not in code search. Which is annoying but manageable if I build the project, but partners who don't will have an even harder time of things.

More recent efforts have us check in generated code alongside the "config" files, and automated processes ensure you check in the generated code if you touch the config file. It's much better this way.

Re:Amazon CodeGuru – Preview by tikkabhuna on Wednesday December 04, 2019 @03:41AM (#21700607)
We generate source code into a "src/main/generated" directory. IntelliJ picks it up like any other source code with proper Gradle configuration and we ignore it with .gitignore.

Only downside we've found is it can be a pain with searching for references in Github and you have to remember to generate the code, but for the most part it is seamless.

I guess how you manage it depends on your IDE, if you can configure it to work nicely, and how much the generated source changes/needs to be read.

Re:Amazon CodeGuru – Preview by dharmab on Tuesday December 03, 2019 @04:02PM (#21696671)
One exception case in our project is documentation- parts of it, like the index, are generated prior to commit. We like having the docs updated in the same commit as the change so there's never an opportunity for mismatch.
Re:Amazon CodeGuru – Preview by scarejunba on Tuesday December 03, 2019 @02:56PM (#21696055)
What would the rationale be for that?
Re:Amazon CodeGuru – Preview by pc86 on Tuesday December 03, 2019 @03:07PM (#21696158)
Generated code is an artifact of the source code. If you need it for something specific, regenerate it from the source when you pull that from your version control system. You're not getting any benefit by storing something that can be generated alongside the means to generate it.
Re:Amazon CodeGuru – Preview by scarejunba on Tuesday December 03, 2019 @04:32PM (#21696946)
Thank you for your response. The advantages you get:

* Hermetic builds are faster because code-gen only occurs when changes occur in the base code

* Lots of docgen tools don't support incremental compilation

* Diffs in generated code show up as diffs when you change the code-gen tool, easier to isolate changes that occur if your code-gen tool is upstream (say you want entire org on Thrift 0.9.2 from Thrift 0.8)

Downsides I can see:

* Large repo.

* Source of truth is now the generated code, not the source, so someone else using the source could get a different result.

Essentially acting in an empirical mode of operation (i.e. does it provide benefits for cost), and ignoring any philosophical objections, this seems like it could go either way depending on the situation.

Re:Amazon CodeGuru – Preview by spyspy on Tuesday December 03, 2019 @05:59PM (#21697797)
> Source of truth is now the generated code, not the source, so someone else using the source could get a different result.

This seems to apply to the other side, I think. Generating from source with different tooling or tool versions could create different results, whereas using the generated code guarantees consistent behavior.

Re:Amazon CodeGuru – Preview by panda88888 on Tuesday December 03, 2019 @03:05PM (#21696143)
IMO it’s because generates code is not “source code”. It’s more similar to object files—both are generated by running a compiler.
Re:Amazon CodeGuru – Preview by JaRail on Tuesday December 03, 2019 @10:53PM (#21699434)
Tools like this should be built into your IDE. No developer ever wants automated feedback at the end of the process in a code review.

There are lots of academic ML review/suggestion tools. Those people come to the table with trials and statistics to assess the quality of their results. Amazon probably copied one of those papers, added a rules-engine to recommend their own APIs, and slapped a hefty price tag on it.

Re:Amazon CodeGuru – Preview by binary_vitamin on Tuesday December 03, 2019 @08:14PM (#21698706)
> I wonder if it's actually good enough to justify that price.

If it can spot a lot of issues (performance, security, bug, etc), $3.75 is definitely a good deal to do it once a while but not on every single changes (e.g. fixing a typo in the code comment)