This is an action of contract in which plaintiff seeks to recover a balance due for labor and materials in remodelling defendant’s dwelling house.
The answer is general denial, payment, defective workmanship, and non-performance. Defendant also filed a declaration in set-off claiming damages for failure of plaintiff to perform his contract. To this declaration, defendant in set-off filed a general denial.
This case is one of two suits, — the other being a counter suit in both of which there were filed declarations in set-off. Plaintiff is pressing an appeal only on one suit and only on one point, — namely, the effect on plaintiff’s suit of his allegedly illegal conduct in acting as contractor while at the same time serving as building inspector of the town of *141Carlisle where the contract was to be performed and where he had for several years been the building inspector appointed annually by the board of selectmen, without any assistant or deputy.
The selectmen were aware that plaintiff was a contractor who occasionally did work in Carlisle. Periodically, plaintiff would submit to the selectmen a list of the building permits issued' so that they knew what work he was doing. The procedure followed on jobs on which plaintiff was working was that he would issue the building permit and report it to the selectmen, but would not make any inspection. In cases where plaintiff was acting as contractor, the selectmen would, if necessary, either make the inspection or appoint a deputy inspector for that purpose.
The building laws of the town, so far as pertinent, are found in the judge’s decision.
After lengthy discussion of phases of the case which are not in issue in this appeal, and after making a finding that plaintiff was entitled to recover, the judge considered the issue before us, — the effect of plaintiff’s violations of the building by-laws of the town of Carlisle, in the following language:
The By-Laws of the Town of Carlisle contain these provisions:
ARTICLE V. BUILDING BY-LAWS
Administration
SECTION i. An Inspector of Buildings, *142hereinafter called the Inspector, shall be appointed annually by the Selectmen for a term of one year or until his successor has been appointed. He shall not be financially interested in any such construction which he inspects.
Section 2. No building within the limits of the Town, other than a one-story building for poultry......... shall be erected, razed, moved, added to or altered in any way, nor the roof thereof be re-shingled or repapered, until the Inspector shall have issued a permit therefor. No such permit shall be issued by the Inspector until a written application therefor and, except in the case of buildings for general farm purposes, complete plans and specifications or a detailed description of the proposed work in duplicate, shall have been filed with the Inspector at least seven days before such work is commenced. If such application and plans and specifications or description shall be found by the Inspector to comply with all requirements of the laws of the Town and the Commonwealth, he shall issue promptly the permit so applied for. If an application for such a permit is denied by the Inspector, he shall notify the applicant in writing of the reasons for such denial.
MISCELLANEOUS ARTICLES
SECTION i. Whoever violates any of the provisions of these By-Laws shall be *143punished by a fine not exceeding twenty dollars ($20).
The judge then goes on to say:
“In connection with the foregoing ByLaws, I find that the plaintiff was in 1959 the duly appointed Inspector of Buildings of the Town of Carlisle and that he was financially interested in the remodelling of the defendant’s building. I find further that he signed an application for a permit to do the remodelling in question for and in behalf of the defendant, issued a permit therefor as Inspector without the previous filing of complete plans and specifications or a detailed description of the proposed work in duplicate; charged the defendant $10.— as a permit fee; and posted a printed card on the building reciting previous inspection.
By way of conclusions from the entire evidence, I find as follows:
(a) The contract between the plaintiff and the defendant was on the basis that the plaintiff was to be paid for labor and materials to be furnished plus a 10% profit on materials furnished.
(b) The plaintiff furnished the defendant labor and materials with a ten percent profit on materials in the amount of $1200. — from which a deduction of $11.— should be made for defective work, leaving a balance of $1189. — , which amount I find to be the fair value of labor and materials *144furnished by the plaintiff and remaining unpaid.
(c) The performance of the .contract between the plaintiff and defendant was done by them in direct violation of Sections 1 and 2 of the By-Laws of the Town of Carlisle although they may have believed that they were proceeding legally and properly.
(d) Section 1 of the Building By-Laws of Carlisle established and defined a public policy respecting the construction and remodelling of buildings that is in the public interest as well as in the interest of property-owners.
(e) The violation by the parties of Section 1 of the Building By-Laws of the Town of Carlisle taints the performance of the contract in question with such illegality, whether or not pleaded, that neither party is entitled to recover against the other under the .circumstances. (Cf. Claflin v. U. S. Credit System Co., 165 Mass. 501, 503; Gerwonka v. Saugus, 316 Mass. 152; Fouquette v. Millette, 310 Mass. 351; Tocci v. Lembo, 325 Mass. 707; Johnson v. Senecal, 329 Mass. 556, 558).”
The only rulings questioned by the plaintiff are Nos. 10, 12, and 13, which with the Court’s disposition are as follows:
10. The plaintiff is not barred from recovering in this action because the complete plans and specifications were not filed with *145the Building Inspector. Palefsky v. Connor, 270 Mass. 410, 416. Granted, with the qualification that this circumstance is to be considered with other circumstances in determining the plaintiff’s claim.
12. There is no evidence of any illegality in the contract or in the consideration thereof which would bar the plaintiff from recovering in this action. Buccella v. Schuster, 340 Mass. 323. Granted.
13. There is no evidence that any illegality in the obtaining of the permit was serious or more than an incidental part of the performance such as to bar the plaintiff’s recovery in this action. Denied.
On motion of plaintiff, the court clarified and corrected its Rulings on Requests 10 and 12 as follows:
“After allowance of plaintiff’s motion to correct Rulings, I clarify and correct the rulings referred to therein, as prayed, as follows:
1. In making my ruling on Request 10, I considered the requirement in Section 2 of the Building By-Laws of the Town of Carlisle (Dft’s Exhibit 2, p 3) for filings of plans and specifications and a delay of seven days thereafter before commencing work and the failure of the plaintiff and defendant to comply therewith under the circumstances as relevant to the plaintiff’s non-compliance with the public policy prohibiting the building Inspector from being *146financially interested in construction inspected by him promulgated by Section 1 of the Building By-Laws (Dft’s Ex. 2, p 3) and as being part of a single plan to disregard inspection requirements, and so distinguishable from Pelofsky v. O’Connor, 270 Mass. 410.
2. Plaintiff’s Request 12 relates to the making of a contract which could have been performed in a legal mode by the plaintiff resigning as Building Inspector. My findings in Paragraphs 12(c) and 12(e) are findings of illegality in the mode of performance of the contract. I clarify and correct my ruling, as prayed, so as to read as follows:
12. Granted with the qualification that although the contract in its inception did not by its terms require the doing of illegal acts the manner adopted by the plaintiff and followed by him in performing it was under the circumstances a manifest violation of the public policy promulgated in and by Section 1 of the Building By-Laws of the Town of Carlisle, on the reasoning and authority of Fouquette v. Millette, 310 Mass. 351, 354, and Tocci v. Lembo, 325 Mass. 707, 710.”
Plaintiff claimed to be aggrieved by the following Rulings:
1. The Court’s ruling in paragraph 12(c) that “the performance of the con*147tract between the plaintiff and the defendant was done by them in direct violation of sections 1 and 2 of the By-Laws of the Town of Carlisle, although they may have believed that they were proceeding legally and properly.”
2. The Court’s ruling in paragraph 12(e) that “the violation of the parties of Section 1 of the Building By-Laws of the Town of Carlisle taints the performance of the contract in question with such illegality, whether or not pleaded, that neither party is entitled to recover against the other under the circumstances.”
3. The Court’s qualified granting of the plaintiff’s request for ruling No. 10 which was “granted with the qualification that this circumstance is to be considered with other circumstances in determining the plaintiff’s claim.”
4. The Court’s denial of plaintiff’s request for ruling of No. 13.
Two questions arise. Is defendant precluded from raising the question of illegality because he failed to plead it in his answer? Does this illegality vitiate plaintiff’s claim?
As to the first issue, Barsky v. Hansen, 311 Mass. 14, 17, holds that in cases where public policy is involved, the issue of illegality may be raised even though it has not been pleaded. Reaffirmed in Cadillac Automobile Company of Boston v. Engeian, 339 Mass. 26, 29.
As to the second issue, the trial *148judge’s opinion clearly and forcibly presents the basis for his ruling that the illegality here involved prevents plaintiff from recovering on what would otherwise be a perfectly sound claim. The reasoning and the authority in support thereof are set forth in his opinion supra and need not be repeated. Incidentally, in defendant’s countersuit for damages in the amount of $6,000 to compensate him for hiring a contractor to finish the work, the court found against him for the same reason that it found for defendant in the suit before us, — namely, on the ground of illegality which tainted the whole contractual relationship.
It is true, as Lord Brougham said in Egerton v. Brownlow, 4 H.L. (Eng.) cas. I-96, quoted in Council v. Cohen, 303 Mass. 348 at 352, that “The Court should proceed with extreme caution when called upon to declare a transaction void on grounds of public policy.”
Now here, as pointed out in the judge’s opinion, plaintiff was financially interested in the transaction. He granted a permit on a $10,000 operation without previously filing complete plans and specifications or a detailed description of the proposed work in duplicate, charged the defendant $10 as a permit fee, and posted a printed .card on the building reciting previous inspections.
The function of the building inspector is to protect not only the current owner, but his successors in ownership. It may take years for a defect to show up which could have been *149detected during construction. If plaintiff did not inspect, it was incumbent on him to get somebody else to inspect his work as it proceeded. In this case, there was no inspection until after plaintiff had been paid some $9,000 for work begun on June 6, 1959, and completed August 9, 1959, subsequent to which plaintiff was discharged and someone else finished the job. The above payments were made between June 26, and August 19. After this latter date, at the request of defendant, one of the Selectmen inspected the premises. Under all these circumstances, to exonerate plaintiff as requested by defendant because he did not inspect, would in effect reward him for remodelling a building without inspection until perhaps too late to detect defects.
It is evident that the trial judge looked on this .case as a whole and concluded that the total picture called for a finding of illegality, with which finding we are not disposed to quarrel.
There is perhaps this further to say, — that even in the short space of time since this case was heard, public attention has become more than ever sharply focused on the subject now known as “Conflict of Interest.” Whether or not actual dishonesty or corruption e'xisted in the operation before us, and plaintiff may well have been innocent, the spirit of the building by-laws was clearly violated. This type of operation involving a public officer presents such obvious oppor*150tunity for improper .conduct that it should not be encouraged. The best way to discourage it is to make it unprofitable. This the Court did. Report Dismissed.
Arthur L. Eno, Jr. of Lowell, for the Plaintiff. Charles W. Nichols of Westminster, for the Defendant.