r/codereview • • 27d ago

4 YOE and I'm already the "old man" about how code gets written. Is it me?

Thumbnail reddit.com
2 Upvotes

r/codereview • • 27d ago

I spent 9 days building ProofPatcher with PHP/Laravel to catch bad AI-generated code. Looking for technical feedback.

1 Upvotes

So I spent the last 9 days building something for the Meta AI Developer Hackathon. Figured I'd share it here and see what other developers think.

It's called ProofPatcher, built with PHP, Laravel, React, Meta Muse, and my own Hari core.

The problem I'm trying to solve is pretty simple: AI can generate a convincing patch, but that doesn't mean the patch is correct.

ProofPatcher can review GitHub PRs, generate inline feedback, propose fixes, and run supported changes through isolated Modal checks. The verification workflow includes reproducing the original failure and testing negative controls, so a trivial shortcut doesn't automatically get a green result.

I also tested a Muse-generated fix that became a draft PR, and separately demonstrated an opt-in bot reviewing and merging a protected test PR.

It's still a prototype. The isolated verification is currently limited to supported fixtures, and the entire issue-to-merge process isn't one fully autonomous workflow. I don't want to pretend otherwise.

I used AI coding assistants during development too, which makes the problem even more interesting to me. If we're going to rely on AI-written code, how do we independently verify what it actually does?

X Link

Source code: proofPatcher

I'd genuinely appreciate feedback, especially on the verification approach, security boundaries, and anything you think I got wrong.


r/codereview • • 27d ago

[JavaScript/Node] Review my Claude Code hooks that lint every file an agent edits (~330 lines, zero deps)

0 Upvotes

I built codemyrules, an open-source agent skill that turns the rules in AGENTS.md / CLAUDE.md into ESLint or ast-grep rules. The part I'd like reviewed is the feedback loop: three small Node scripts that run as Claude Code hooks, plain ESM, no dependencies, tests with node:test.

  • guard.mjs (PreToolUse, 68 lines): asks the user before the agent adds an eslint-disable / @ts-ignore / noqa etc. or edits a lint config.
  • lint-edited.mjs (PostToolUse, 39 lines): runs the fast linters on the edited file and blocks only on errors in lines changed since HEAD.
  • lint-turn.mjs (Stop, 40 lines): runs all linters on every file edited in the turn.
  • lib.mjs (181 lines): diff hunk parsing, linter output parsing, config, the secret-file deny list.

Code: https://github.com/clirimajeti/codemyrules/tree/main/skills/codemyrules/scripts

What I'd especially like eyes on:

  1. The suppression regex in guard.mjs**.** Can you think of a way an agent could silence a rule that it misses, or a false positive that would annoy you?
  2. parseHunks in lib.mjs**.** It parses git diff -U0 output to find changed lines. Edge cases I've missed (renames, binary files, odd file names)?
  3. Speed. The PostToolUse hook runs after every single edit. Anything obviously slow?
  4. Failure modes. A broken hook must never block the agent forever or leak a credential file. Anything that could?

Run the tests with node --test skills/codemyrules/scripts/test/*.test.mjs. Honest feedback welcome.


r/codereview • • 28d ago

Rust Seeking Lean 4 & Crypto Reviewers for Sovereign-Mohawk Protocol

Post image
0 Upvotes

r/codereview • • 27d ago

AI Broke Cybersecurity. Visual Programming Can Fix It.

Post image
0 Upvotes

AI broke cybersecurity: code is written faster than we can review, detection is blind, and patching is too slow. Visual language Pipe fixes all three—code becomes reviewable by construction, and every block stays observable and patchable at runtime by design.

AI shook the very foundation of cybersecurity. It upended established practices and assumptions. Anyone can now use AI to scan code and find vulnerabilities quickly. What’s even worse, bugs found during one pass of AI code scanning might not be reported after rescanning. This is because of the probabilistic nature of AI – it gives a different response to the same prompt. It means that someone can find a zero-day vulnerability that may not be rediscovered on a later scan, even using the same AI model and identical source code. This could let one person discover and exploit a zero-day that others never see.

Cybersecurity problems are quickly growing in many cybersecurity-related aspects simultaneously. Let’s focus on three of them. They are: (1) AI generates code faster than teams can review it; (2) runtime threat detection is unreliable; and (3) patching is too slow. I will divide the analysis into two stages: development (design-time), and production (runtime).

Problem 1 – Development: code faster than review

A problem AI brought to development impacts cybersecurity indirectly, but it is still a significant threat. AI generates code in huge amounts so fast that development teams cannot review it in a reasonable time. Add to this the pressure on development teams to deliver productivity gains due to AI implementation, and the situation becomes even more dire. Teams have no choice but to skip detailed review, approving PRs automatically. This results in bugs slipping into the codebase and eventually causing crashes and vulnerabilities in production.

The most popular proposed solution is using AI for code review. Essentially, we are going to use AI to review code produced by another AI. There are problems with such a solution due to certain properties of AI itself. The main issue is that AI is bad at handling big context: the longer the task or instructions you give it – the more it hallucinates and the more sharply it degrades on a very large context. I face this problem all the time when trying to ask AI to generate code for even a modest, clearly detailed specification - AI skips, misinterprets and deviates from the specification a lot. The workaround is to have AI generate only scaffolding and continue step-by-step in a tool like Cursor – which proves the point: the model can’t handle the whole codebase. A codebase is a very large context for AI. Are we confident enough to trust AI 100% that the quality of its code review will be comparable to a human’s, even after multiple rounds? Probably not, and this is why human eyes are still needed. It means we are back to square one - dealing with an enormous wall of text code.

Now we will look into the production post-deployment stage. There are two closely related problems there: one is about the reliability of threat detection, and the other – the speed of reaction to an attack.

Problem 2 – Production: detection is blind

Let’s start with detection. The single source of information about what’s happening inside the application is log data. Log statements are pre-placed by developers in source code locations where they think it is necessary. Very often, needed log statements are missing and therefore, any threat detection system (no matter if it is AI-driven or not) can be blind to certain types of attacks. We cannot blame developers for that, because they cannot predict the future. This is the failure of the observability process relying solely on logs to get runtime information about application behavior.

Problem 3 – Production: patching is too slow

Another problem is a reaction to a known attack or vulnerability. The standard process is going back to source code, investigating the problem, changing the code, approving/merging a PR and deploying via CI/CD. The whole process might take days or weeks, even if a new deployment starts fast. The deployment itself might take several days, because often, deployment stages have heavy tests attached that need significant time to complete execution. I worked for companies running complete application tests on every deployment stage to ensure the highest quality of the deployment, but at the heavy cost of the speed. The question is what the production team is going to do while waiting for the fix deployment. They have two choices. One is just waiting, assuming that nobody will exploit the discovered vulnerabilities and data will not be stolen as a result of it. This might be true in the pre-AI era. However, the frequency of AI-driven cyberattacks is growing very fast, and we might not be able to afford to wait today – the risk of losing data is much higher. An alternative is shutting down the whole system or a large independent module while we wait for the fix. However, it will break the continuity of the business. As we can see, both options are bad.

So, we identified three problems – one during development (AI code is generated too fast), and two during production (detection is unreliable and patching is slow). There is a variety of tools and approaches trying to solve these problems. However, their reliability and simplicity are questionable. For example, we can try to disable a certain part of the application using feature flags and tools like LaunchDarkly. However, the whole process of feature flag management is complicated, and it gets exponentially complex as the number of feature flags increases. We need to test many combinations of feature flags during deployment so that we can be confident switching them live on production does not break the application. I worked in companies that used feature flags, and they had a policy to remove a feature flag as soon as it is no longer needed to avoid the complexity of deployment tests.

One solution for all three: visual programming

There is one approach that fixes all three problems at once: visual programming – and I am working on such a solution. This is an unusual combination, but such an approach was proposed before. What’s different this time is a more powerful visual language “Pipe” I designed. This visual language combines two properties not usually seen together in other VPLs: generality and power. Usually, relatively powerful visual languages are domain-specific, while general-purpose languages are pretty simple. I spent 7 years closing this gap and designing a VPL that has both properties together. The reason we need a VPL to be general-purpose and powerful at the same time is that all text-based languages have both properties, and that’s the reason they dominate. Just to have a real opportunity to absorb a part of text code (no visual language can fully replace text code, even Pipe), a VPL must have similar properties to text-based programming languages. Let’s see how Pipe solves the three problems outlined above.

How Pipe solves each problem

The first problem is that it is humanly impossible to review huge amounts of AI-generated code in a reasonable time. This application of VPL is obvious – visual logic is much easier to grasp. VPL does not solve the problem completely, but it mitigates it. As I mentioned before, no VPL is able to fully replace text code, so it will be a mix of visual diagrams and text code. The bigger the proportion of logic moved to visual diagrams from text code, the bigger the benefit of reviewing logic visually is going to be. AI will be generating visual diagrams with some code inside, instead of 100% text code as it does now.

The other two problems (observability and patching) rely on the same property of Pipe – its powerful semantics allows it to keep the visual graph not only during development, but also on production. The reason semantics needs to be powerful enough for this is that otherwise a VPL needs to be translated to a text language to fill missing details in text code, because the VPL itself is not powerful enough to cover it with visual code. So, the deployment chain in this case goes via text, losing the visual graph.

Having a full visual graph on production allows direct access to visual blocks. This has profound consequences both for observability and patching. Observability can be dynamic by tapping monitoring directly into the inputs and outputs of any block at any time right on production, in real time, replacing or complementing log data. Patching also becomes faster because the block can be patched, disabled or rerouted directly, right on production.

A concrete example: a payment-validation block starts leaking customer data. Today a team files a ticket, changes the code, runs the full test-and-deploy cycle, and hopes no one exploits the hole in the meantime. With Pipe, an operator taps that block’s inputs and outputs, confirms the anomaly in real time, and reroutes traffic to a safe fallback block in seconds – while the permanent fix goes through normal CI/CD. The vulnerability is contained immediately; the business keeps running.

Isn’t changing production live dangerous?

I anticipate a very reasonable objection that direct modification of application behavior on production is dangerous and it can cause cascading failures. This is an absolutely legitimate concern. There are two possible solutions.

One solution is separating eventual problem solving and immediate reaction. For example, we can disable a single block or a group of blocks related to just one application feature, not impacting the rest of the application. At the same time, we ask developers to start working on a fix that will go via a normal CI/CD cycle. This way, we do not have to choose between two bad options: shutting down the whole application or assuming nobody will hack the system while a fix is in the works. What Pipe offers is the third option – shutting down or rerouting a vulnerable or dangerous part of the application temporarily, while we wait for a fix. Having such abilities requires a prepared manual giving clear instructions on what to disable in specific situations – developers must prepare such manuals. The good news is that it should not be a burden as AI will be able to help here.

Another solution is building a more sophisticated delivery process with testing right on production, leveraging direct access to blocks to tap the test suite into inputs and outputs, sending testing data to inputs, and analyzing responses from outputs. This process does not necessarily have to fully replace a normal CI/CD deployment – it can complement it to ensure the quality of the direct fix until a new CI/CD deployment arrives.

The key idea of defense against AI-driven cybersecurity attacks is also using AI. However, AI for attack is different from AI for defense. AI for attacks must exploit just one vulnerability – a physical analogy is a sharp, pointy spear. AI for defense must be solid and without holes (a shield), because we do not know beforehand where precisely an attack (a spear) is going to hit. However, AI built on top of existing systems will have lots of holes in the shield, and patching these holes will be slow.

The hot trend today is self-healing engines – an intelligent AI layer on top of the application, detecting attacks and reacting to them automatically. There are two key requirements for such an engine: reliable detection and real-time reaction. However, it is very hard to satisfy these requirements in current systems due to the reasons outlined above: detection is unreliable as the engine can use only fragmented data from logs (shield holes), and reaction is slow as the fix needs to go via the full CI/CD deployment (slow patching of shield holes). What Pipe offers is a solid foundation for such self-healing engines providing reliable detection and fast reaction.

Doesn’t this mean rewriting everything?

The most frequent argument I hear against Pipe is that it requires rewriting existing applications – it is true. However, Pipe only complements text code, mixing visual logic with text. It means that migration does not need to retire the existing codebase immediately. Instead, the migration can be gradual – starting by encompassing the whole application or module in one root Pipe block. Then, whenever ready, moving one step below and distributing text code inside the root block between visual blocks of a second-level workflow, etc. You can stop subdividing blocks at any point, so it's entirely your decision which parts of the system become visual and which remain as text. Pipe provides a complete API for integration with text languages as part of the specification. Also, AI can automate workflow generation, text code distribution between visual blocks, connectivity, and layout of all visual components.

Like everything else in engineering, Pipe has its upsides and downsides. The biggest downside is the need to rewrite existing applications. However, there is also a significant upside – solving three critical cybersecurity issues all together, by the design of the solution. Considering the explosion of AI-driven cybersecurity threats, the current security model might already be outdated and we need to change it. So, weighing upsides against downsides, the upsides definitely win.

Can we create runtime components from text code?

Yes – and it has been tried many times. But every time, managing those components gets complicated: the more you have, the more complex the web of their interactions becomes. The winning combination isn’t just highly granular software in production – it’s also a visual representation that makes all the relationships between them visible. This matters for both observability and patching: the visual graph shows you exactly which components to tap into, and which blocks to patch, disable, or reroute.

Why now

Computers of the 1970s and earlier had only a text-based terminal interface requiring knowledge of specific commands, so the UI was very unfriendly. The GUI revolution brought windows, icons, buttons, and other graphical elements. This made computers much more accessible to users. However, programming did not make this transition, and we still program using text only. AI is the catalyst that finally forces the move to visual programming – not because it’s nice to have, but because we no longer have a choice.

Website: https://pipelang.com

Pipe IDE URL: https://www.pipelang.com/pipe/v1/

Tutorials:

  1. Data Swap – https://www.pipelang.com/assets/tutorials/v1/tutorial1.mp4
  2. Reusable Sum – https://www.pipelang.com/assets/tutorials/v1/tutorial2.mp4

r/codereview • • 29d ago

What's the strangest "passes locally, fails only in CI" bug you've tracked down?

Thumbnail reddit.com
1 Upvotes

I've been collecting the usual suspects for CI-only failures. Most of the time it turns out CI isn't the problem, it's something my local machine was quietly giving the test for free:

- Speed: the CI runner is slower, so any check that doesn't wait or retry (isVisible(), reading text straight after a click) passes locally and fails there.
- Leftover state: locally I'm already logged in or the test data already exists. CI starts clean.
- Environment: a .env that only exists on my machine, or the runner being on UTC so date assertions break.
- Parallel workers: tests that pass alone but fight over the same data when run together.

My rule now is to open the trace from the failed CI run before touching retries. It usually points at one of these within a few minutes.

What am I missing? Curious about the weird ones: fonts, screen size, locale, DNS, anything.


r/codereview • • 29d ago

I built a tool that explains GitHub PRs by code flow instead of file by file

Post image
0 Upvotes

r/codereview • • Nov 03 '26

Units of measure in code: four layers of defense, from cheapest to strongest

0 Upvotes

A bug class that’s easy to write and hard to see in review: a number with no unit. timeout = 30 is 30 seconds in one function and 30 milliseconds in another, and nothing complains.

The famous documented example is the Mars Climate Orbiter, lost in 1999. As I understand the investigation, one piece of software produced thruster impulse data in pound-force seconds while another expected newton-seconds. I’d treat the details with some caution, but the lesson is widely cited: the numbers were fine, and the unit was missing.

Here are four layers of defense. Each is more work than the one before and catches more.

Layer 1: put the unit in the name

timeout_seconds = 30
distance_meters = 120.5

Costs nothing, and makes a mismatch visible at the call site. Also name function parameters this way: def wait(timeout_ms: int).

Layer 2: make the type carry the unit

from datetime import timedelta

def fetch(url, timeout: timedelta): ...

fetch(url, timeout=timedelta(seconds=30))

Standard library types already do this for time. For other quantities, a small wrapper or a units library (in Python, a package like pint) turns a unit mismatch into an error instead of a silent wrong number. The cost is extra code and some learning curve.

Layer 3: convert at the boundary
Inside your program, pick one unit per kind of quantity (for example, everything in SI units, all times in UTC seconds), and convert at the places where data enters or leaves: files, APIs, user input, other systems. Document what each external field means.

Layer 4: test with values you know from outside
A test that uses a known conversion from a reference (for example, 1 inch is exactly 25.4 mm) can catch a wrong factor. A test that computes the expected value with the same formula as the code only repeats the mistake.

Where this is overkill: small scripts, and code where only one unit ever appears. I’d start with Layer 1 everywhere and add the others where mistakes are expensive: money, physical measurements, medical doses, billing by usage.

Other places units hide: currency (cents vs dollars, and which currency), percentages (0.05 vs 5), angles (degrees vs radians), and timestamps (seconds vs milliseconds since the epoch).

What’s the most common unit mix-up you see, and which layer do you actually use?


r/codereview • • Nov 03 '26

C/C++ [C] Bro what is this code 💀🥀

0 Upvotes

Somone don't know about C's global variables

(Sorry for bad formatted code)

#include <stdio.h>

int x = 0;

void add()

{

x = x + 1;

}

void subtract()

{

x = x - 1;

}

void multiply()

{

x = x * 2;

}

int main()

{

add();

add();

multiply();

subtract();

printf("%d\n", x);

return 0;

}


r/codereview • • Nov 03 '26

javascript Is AI making you spend more time reviewing code than writing it?

0 Upvotes

r/codereview • • Nov 03 '26

AI writes code faster than anyone can review it. What makes an automated review actually useful instead of noise?

0 Upvotes

Something we keep running into, and we'd like this sub's take on it.

AI coding tools have made writing code cheap, so the pile waiting for review keeps growing. The obvious answer is to have an AI review it too, but most automated reviews we've seen fall into the same traps:

  • Too many comments, mostly style. Twenty nitpicks about naming bury the one real bug.
  • Findings nobody checked. "This might cause a null reference" on a line where it can't happen. After a few of those, people stop reading.
  • No reason given. "Consider handling this edge case" without saying which input breaks it.
  • It changes the code. You asked for a review and got a rewrite you now have to review as well.

We build a coding agent (CCode), and while adding a review command to it we settled on a few rules. We're curious whether people who review code for a living agree:

  1. Order by severity: bugs, then security, then missing tests for the change, then minor issues. Style is last, if at all.
  2. Check every finding against the code before reporting it, and drop what can't be backed up. A shorter list you can trust beats a long one you have to verify.
  3. Every finding comes with a concrete case where it goes wrong. Not "may fail", but "with an empty cart this returns NaN". Plus the file and line, and the fix in one sentence.
  4. End with a one-line verdict. And if there's nothing worth changing, say so plainly instead of inventing something.
  5. Read only. The review never touches the files. Fixing is a separate step you choose.

It runs on uncommitted changes by default, or on a branch, commit or PR.

What would you add or change? In particular:

  • Should missing tests rank above security for a typical change, or below?
  • Is "nothing worth changing" a result you'd trust from an automated review, or would you rather it always found something?

r/codereview • • Nov 02 '26

How is your team keeping track of what AI coding agents are configured to do across repos?

2 Upvotes

Engineers on a lot of teams now commit agent config to their repos: instruction files, skills, MCP server configs. Some of these can run scripts or connect the agent to outside tools, but in review they just look like a small config change.

For those of you whose teams use coding agents heavily:

  • Do you know which skills and MCP servers are in use across your repos?
  • Does anyone review changes to them, or are they treated like any other file?
  • Has this caused an actual problem, or come up in a security review?
  • If you handle it somehow, what do you do? Scripts, CODEOWNERS, a policy doc, nothing?

I'm trying to find out whether this is a real problem or one I've imagined, cuz my team literally does not care about this, but it messes with me a lot in practice.


r/codereview • • Nov 02 '26

Built a standard-library reference repo covering Go backend patterns (Concurrency, Networking, Resiliency, Memory, Architecture) — looking for code review and feedback

3 Upvotes

Hi everyone,

I’m a Computer Engineering student focusing on Go backend engineering. Rather than relying entirely on heavy third-party frameworks, I spent the last few weeks building go-backend-patterns from scratch—an educational reference repository implementing production patterns using standard library primitives and golang.org/x/sync.

Every module is tested under -race and includes a custom goroutine leak detector (internal/leaktest). The repository is structured across 5 distinct pillars:

  1. Concurrency (concurrency/): Bounded worker pools with graceful drain, multi-stage pipelines, fan-out/fan-in workers, errgroup error propagation/cancellation, and or_done channel wrappers.
  2. Networking (networking/): Signal-driven graceful HTTP server shutdown, tuned HTTP client transport pools, composable HTTP middleware chaining, standardized API envelopes, and SSE streaming with client disconnect detection.
  3. Resiliency (resiliency/): Atomic 3-state circuit breaker FSM, token bucket rate limiting via lazy mathematical replenishment, and exponential retry backoff with Full Jitter.
  4. Memory Performance (memory_performance/): Reusable byte buffers with sync.Pool and maxCap clamping to prevent memory bloat, alongside lock-free metrics using sync/atomic arrays and static histogram buckets (0 B/op).
  5. Architecture (architecture/): Functional options with fail-fast validation, context-driven transaction runner (transaction_runner) with named-return panic safety, and generic Cache-Aside with singleflight stampede mitigation and context.WithoutCancel.

Since I am learning independently without local peers to bounce ideas off of, I would really appreciate honest critiques on any package that catches your eye. Whether it’s idiomatic Go style, edge-case safety, or architectural trade-offs, I want to learn what can be improved.

Repo: https://github.com/Cankutay3104/go-backend-patterns

Thanks in advance to anyone who takes a look!


r/codereview • • Nov 02 '26

How to build an automated refactoring engine without breaking your codebase

Thumbnail interconnectd.com
1 Upvotes

Most engineers agree that technical debt accumulates faster than sprint capacity allows. But turning refactoring into an automated pipeline is notoriously tricky—one wrong AST transformation or unhandled edge case can break silent behavior across a repository.

​Building a reliable automated refactoring engine requires more than basic LLM prompts. You need strict static analysis, safe syntax tree modifications, deterministic verification steps, and clear rollback strategies before code ever reaches a pull request.

​I put together a complete engineering breakdown covering the architecture behind automated code refactoring. It covers parsing ASTs, designing guardrails, validating structural changes, and integrating automated codemods directly into CI/CD pipelines: https://interconnectd.com/blog/74/automated-code-refactoring-the-complete-architecture-engineering-guide/

How is your team currently handling large-scale codebase migrations or technical debt cleanup—manual sweeps or custom scripts?


r/codereview • • Nov 01 '26

I’ve been building an open-source project called Grafito — a place to manage documents, connect knowledge.

5 Upvotes

Hey everyone!

I wanted to share a project I've been working on called Grafito. It's an open-source, self-hosted platform that started around document management, but has gradually grown into something a bit broader.

The idea is to bring documents, notes, collaboration, and AI together instead of having information scattered across different tools.

Here's what it currently supports:

  • Document management: Organize files and folders into nested portfolios and workspaces, with version history, trash, and S3-compatible storage.
  • Knowledge management: Create Markdown notes, link them using [[wiki links]], use tags and backlinks, and explore connections through a knowledge graph.
  • Collaboration: Share documents and portfolios with users or organizations, configure permissions, leave comments, mention people, and collaborate on content.
  • Office integration: Edit Office documents through Collabora, including collaborative editing.
  • PDF signatures: Add signature fields to PDFs, request signatures from other users, and support image-based signatures or personal digital certificates.
  • AI assistant: Connect cloud providers like OpenAI, Claude, Gemini, Grok, DeepSeek, and others, or use local models through Ollama and LM Studio. The assistant can search, read, create, and edit notes according to the user's permissions.
  • Authentication: Supports local accounts, LDAP, OAuth, and OpenID Connect.

It's self-hosted and can be deployed with Docker Compose. The goal is to give people and organizations more control over their information while making that information easier to connect, find, and actually use.

I'm still actively developing it, so there's plenty of room for improvement. I'd genuinely love to hear what you think:

  • Does this combination of document management, knowledge graphs, and AI make sense to you?
  • What features would you find useful in a platform like this?
  • Is there anything you think I'm approaching the wrong way?

You can check it out here:

https://github.com/Seerendo/grafito

This isn't just a release announcement — I'm sharing it because I'd like to get feedback from the community and hopefully have some people interested in exploring or contributing to it.

Thanks for taking a look!


r/codereview • • Nov 01 '26

[JAVA] - Loan Repayment Calculator looking for review

Thumbnail reddit.com
2 Upvotes

import javax.swing.JOptionPane;

import java.io.PrintStream;

/**

* Interactive Loan Monthly Payment Calculator

* Architecture: Simple Sequence Structure

* Inputs: JOptionPane GUI Dialogs

* Output: System PrintStream & GUI Summary

*/

public class LoanCalculator {

public static void main(String[] args) {

// Stream reference initialization

PrintStream streamOutput = System.out;

// ------------------------------------------------------------------

// STEP 1: INTERACTIVE GUI INPUTS (SIMPLE SEQUENCE)

// ------------------------------------------------------------------

String principalInput = JOptionPane.showInputDialog(

null,

"Enter the Loan Principal Amount ($):",

"Loan Calculator - Step 1 of 3",

JOptionPane.QUESTION_MESSAGE

);

String annualRateInput = JOptionPane.showInputDialog(

null,

"Enter the Annual Interest Rate (e.g., 5.5 for 5.5%):",

"Loan Calculator - Step 2 of 3",

JOptionPane.QUESTION_MESSAGE

);

String yearsInput = JOptionPane.showInputDialog(

null,

"Enter the Loan Term in Years:",

"Loan Calculator - Step 3 of 3",

JOptionPane.QUESTION_MESSAGE

);

// ------------------------------------------------------------------

// STEP 2: DATA PARSING & VARIABLE TRANSFORMATIONS

// ------------------------------------------------------------------

double principal = Double.parseDouble(principalInput);

double annualRate = Double.parseDouble(annualRateInput);

double years = Double.parseDouble(yearsInput);

// Convert annual rate percentage to monthly decimal rate (r)

double monthlyInterestRate = (annualRate / 100.0) / 12.0;

// Convert total years to total number of monthly payments (n)

double totalMonths = years * 12.0;

// ------------------------------------------------------------------

// STEP 3: SEQUENTIAL FORMULA EVALUATION

// Payment = (Principal * interest) / [1 - (1 + interest)^(-n)]

// ------------------------------------------------------------------

double numerator = principal * monthlyInterestRate;

double denominator = 1.0 - Math.pow(1.0 + monthlyInterestRate, -totalMonths);

double monthlyPayment = numerator / denominator;

double totalRepayment = monthlyPayment * totalMonths;

// ------------------------------------------------------------------

// STEP 4: STREAM OUTPUT PROCESSING & GUI DISPLAY

// ------------------------------------------------------------------

// Direct stream write to System.out

streamOutput.println("=================================================");

streamOutput.println(" LOAN PAYMENT CALCULATION ");

streamOutput.println("=================================================");

streamOutput.printf(" Principal Amount: $%10.2f%n", principal);

streamOutput.printf(" Annual Interest Rate: %10.2f%%%n", annualRate);

streamOutput.printf(" Term Duration: %10.0f years (%d months)%n", years, (int)totalMonths);

streamOutput.println("-------------------------------------------------");

streamOutput.printf(" MONTHLY PAYMENT: $%10.2f%n", monthlyPayment);

streamOutput.printf(" Total Cost of Loan: $%10.2f%n", totalRepayment);

streamOutput.println("=================================================");

// Summary Dialog to close the interactive session

String summaryMessage = String.format(

"Calculation Summary:\n\n" +

"Principal: $%.2f\n" +

"Annual Rate: %.2f%%\n" +

"Term: %.0f years\n\n" +

"Estimated Monthly Payment: $%.2f\n" +

"Total Repayment: $%.2f",

principal, annualRate, years, monthlyPayment, totalRepayment

);

JOptionPane.showMessageDialog(

null,

summaryMessage,

"Loan Payment Result",

JOptionPane.INFORMATION_MESSAGE

);

}

}


r/codereview • • Nov 01 '26

dont skip code review

Thumbnail youtu.be
3 Upvotes

r/codereview • • Nov 01 '26

C/C++ [Code Review] Wrote a fast binary STL inspector/analyzer in C – looking for feedback on memory management and math logic

1 Upvotes

Hi everyone,

I've been working on a lightweight CLI tool in C called stl-inspector (GitHub repo).

Why I built it:

I got tired of waiting for heavy slicers (PrusaSlicer, Cura, Bambu Studio) just to check basic parameters like watertightness, mesh volume, overhang areas, and bounding dimensions of 3D models.

What it currently does:

  • Parses binary STL headers and triangle arrays
  • Calculates bounding box, volume (tetrahedron method), and surface area
  • Detects overhang areas (default 45°) for 3D printing feasibility
  • Checks if the mesh is watertight
  • Fast build with zero external dependencies (pure C + Makefile)

Where I'd appreciate feedback:

  • Memory safety & cleanup (handling large meshes)
  • Performance of the watertight check (currently O(N^2), looking into spatial hashing / edge mapping)
  • General C code idiomatic style and CLI argument handling

Note: AI was used to help debug directory creation.

Would love to hear your critique or suggestions for improvement.


r/codereview • • Nov 01 '26

Python 👾 BugHunt Weekend Raid #36: Defeat The Heisenbug Prime (Python) ⚔️

Thumbnail reddit.com
1 Upvotes

r/codereview • • Oct 31 '26

javascript 👾 BugHunt Weekend Raid #35: Defeat The Stack Overflow Drake (JavaScript) ⚔️

Thumbnail reddit.com
0 Upvotes

r/codereview • • Oct 31 '26

Co-Review: an MIT-licensed desktop app for reviewing a whole repository with your coding agent, like a pull request

Thumbnail reddit.com
3 Upvotes

r/codereview • • Oct 30 '26

Here is my Python GitHub projects showcase, and I would love feedback

Thumbnail github.com
2 Upvotes

r/codereview • • Oct 29 '26

I want you guy to roast at my learning-focused CLI project about lightweight TCP network scanner written in Go. (Nmap inspired heavily on this project)

2 Upvotes

I made Sentinel because I want to learn how to programming in the era that EVERYONE IS USING AI for coding. It doesn't perfect. But, I want to learn, learn fundamental about programming and next level is going to be like Low-Level and System Distributed in the future. I used AI to guide, teach concept, tracking progress, not to coding for me or make decision for me.

About the project: it a lightweight TCP network scanner written in Go called Sentinel. Scan TCP ports on an IPv4 address. Inspired by Nmap

So, for who that past this post to point out, teach me more that AI could never spot on for me. I want you guy to teach me for next session or learning project about Low-Level fundamental, I would keep it in mind. Not to roast at me personally but for my code. It would be great to get a recommendation about what to know, what to keep eyes on it, what to aware. specially about error handling and engineering mindset.
Btw I'm going to attending to the university for next semester🙏

https://github.com/VextorHorizon/sentinel