Fundamentals 6 min read

Can Deleting Code Comments Land You in Court? Legal Risks Explained

The article examines the criminal and civil legal boundaries of deleting code comments in the IT industry, outlines the criteria for severe consequences, analyzes the technical difficulty and cost of such actions, and shares expert and community perspectives on why this practice is largely harmless yet potentially liable.

ITPUB
ITPUB
ITPUB
Can Deleting Code Comments Land You in Court? Legal Risks Explained

Legal Boundaries

In the IT sector, the phrase “deleting the database and running away” is a common vent, but the law also asks whether merely deleting code comments can be illegal.

Criminal Dimension

According to Article 286 of the Criminal Law interpretation, a crime of destroying computer information systems requires two elements: the system becomes inoperable and serious consequences follow. Courts consider the following as serious consequences:

More than ten computers’ main software/hardware become unrecoverable.

Illegal control over more than one hundred computers.

Direct economic loss exceeding 50,000 CNY.

Service interruption for over ten thousand users lasting more than one hour.

Because removing comments does not directly affect code execution, it usually does not meet these criteria and rarely triggers criminal liability.

Civil Dimension

Under Article 90 of the Labor Contract Law, an employee may be liable for compensation if they:

Intentionally damage the employer’s property.

Leak trade secrets.

Violate non‑competition agreements.

Whether comments count as “property” is debated, but a 2021 Hangzhou Internet Court ruling treated code comments as an “organic component of intellectual labor results,” deeming malicious deletion a violation of Article 1165 of the Civil Code.

Technical Impact

Historically, a 1970s case involved a programmer replacing all comments with nonsense, causing years of reverse‑engineering effort. Modern high‑level languages and ubiquitous version‑control systems make restoring comments trivial—simply roll back to a previous commit.

Cost‑Benefit Analysis of Destructive Operations

Three typical destructive actions are compared:

Deleting a production database : Recovery difficulty ★★★★★, requires physical backups, legal risk = criminal crime.

Deleting core algorithm code : Recovery difficulty ★☆☆☆☆, traceable via git blame, legal risk = criminal/civil.

Deleting code comments : Recovery difficulty ★☆☆☆☆, traceable via git blame, legal risk = civil dispute.

Community Opinions

“I might not even be able to handle my own code at this company, let alone delete comments!”
“With version control, restoring comments is just a rollback. Instead of wasting time, write inefficient code to vent frustration—like reading files byte‑by‑byte, which slows performance dramatically.”
“Deleting comments is useless; just introduce bugs and laugh.”

Conclusion

Since modern code management retains full modification history, the prudent approach when leaving a job is to perform a proper handover rather than attempting to delete comments, which offers no real advantage and may invite civil liability.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

code commentssoftwarelegalcivil liabilitycriminal law
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.