Will there be any positive gain thanks to the publishing of the code to me?
Publishing the code is necessary to make the calculation reproducible and the results verifiable. If I were the referee of your paper I would likely insist that you publish the code. So the “positive gain” would be that your paper will not be rejected outright. It will also help your reputation and build up other researchers’ impression of you as a serious, careful scientist who understands what it means to do good science.
Besides, what you are asking is essentially “is there a positive gain to behaving honestly”. I’m not going to enter a philosophical discussion about honesty and its benefits here, but just think for a second about what you’re saying. Even in a specific context of academic research, your question can be rephrased as “I am thinking of hiding information about the way I did my research that would be essential for other researchers to verify my results. Is there a positive gain from not hiding this information?” Again, think about what you’re asking.
It’s clear from the question that you are in fact a person who is motivated by a desire to advance science and wants to do the right thing. That’s great, and the conclusion is that it is your duty to disclose the relevant information about your research that would enable other researchers to check your results. If the results later turn out to be invalid, then you and the journal you published in would need to deal with it in an appropriate and responsible way, either by issuing a note pointing out the error, or (which typically would happen only in really extreme, egregious circumstances) by retracting the article. Honestly I don’t think this is something to worry about too much. As long as you’re acting in good faith and doing your best to do good science, you are adding to the sum total of human knowledge and your work has value. That’s what matters, and that’s what you will ultimately be judged on by your peers in the community.
Edit: my opinion about requiring authors to make code available as a condition for publication generated some controversy in the comments, but I find the arguments for allowing authors to withhold code to be quite weak. I suggest that people think more about this issue, and consider in particular the fact that the Nature Research family of 148 journals has exactly the requirement I suggested as part of its official policy:
Reporting standards and availability of data, materials, code and protocols
An inherent principle of publication is that others should be able to replicate and build upon the authors' published claims. A condition of publication in a Nature Research journal is that authors are required to make materials, data, code, and associated protocols promptly available to readers without undue qualifications. Any restrictions on the availability of materials or information must be disclosed to the editors at the time of submission. Any restrictions must alsobe disclosed in the submitted manuscript.
After publication, readers who encounter refusal by the authors to comply with these policies should contact the chief editor of the journal. In cases where editors are unable to resolve a complaint, the journal may refer the matter to the authors' funding institution and/or publish a formal statement of correction, attached online to the publication, stating that readers have been unable to obtain necessary materials to replicate the findings.