Ethical factors to consider in case of a non-contributing co-author I am a Ph.D. student. Currently, we are writing a paper. We can group the participants in the following way:

Me and my collaborators who have done the majority of the work.
My principal supervisor who helped me to access the lab.
The person, let's call him Glideroy :-) , who is the subject of this question.

Glideroy has not made any substantial contribution. To be precise, he wrote one piece of code, which eventually was not used in the paper. Later we asked him for further investigation, which he didn't do.
One of our co-authors expressed his reluctance to include the non-contributing co-author's name in the paper. According to him, the decision is in the hand of the authors who have made a substantial contribution. My principal advisor is not aware of this yet, but he has a good relationship with Gilderoy.
Now I am in a tricky position, I agree with the non-contributing part. However, I feel a bit hesitant to burn the bridge and remove the author altogether. So, my questions are the following:

What are the criteria one should fulfill to be a co-author?
Should I talk to my principal supervisor?
Is there any way we can justify the inclusion of Glideroy's name?

Any advice would be helpful.
The criteria to be a co-author depend on the field of research and on the journal, but usually at least some intellectual contribution to the paper is expected. Most journals have a list of requirements on their website.
Yes, you should talk to your supervisor: this will probably solve the problem.
No, unless the code he wrote gave you important insights (even if the code was not used afterwards). But also see the answer to (1).

There are three possible outcomes:

Your supervisor agrees to remove the co-author.

Your supervisor convinces you that the contribution of the co-author was enough to earn authorship.

Your supervisor wants to include the co-author for &quot;political&quot; reasons. This is wrong, but it happens quite a lot unfortunately. In this case it would probably be best to include the co-author anyway. It is wrong ethically, but if you and your co-authors did your best to prevent it that is on your supervisor and not on you: if you discussed it with him there is not much more you can do unless you want to risk the relationship with your advisor.