The way a path is shaded leads to a wrong actual shading angle. When shading a path with a rotated shading, the shading is first rotated by the requested shading angle and then scaled, which introduces a distorsion and modifies the shading angle as soon as the bounding box of the path is not a square or the shading angle is not a multiple of 90°. If the dimensions of the bounding box are (w,h) and the requested shading angle is α then the actual shading angle is
θ = tan⁻¹(h/w * tan(α)).
When reading the code of \pgfshadepath in pgfcoreshade.code.tex, it seems that the order of operations is shift, scale, rotate as claimed in the pgf manual. But since these operations are applied to the canvas, the effect is actually the converse: rotate, scale, shift.

In order to shade a rectangle of dimensions (w,h) rotated by an angle β, so that the shading is parallel to the axis of the rectangle, one could expect the following to work:
\draw[rotate=β,shading=axis,shading angle=β] (0,0) rectangle (w,h);
But in fact, if h/w=1/4 and β=20°one gets this
\draw[rotate=20,shading=axis,shading angle=20] (0,0) rectangle (4,1);

To get the desired result, one must use a shading angle
α = tan⁻¹((1+h/w |tan(β)|)/(h/w + |tan(β)|)tan(β))
\draw[rotate=20,shading=axis,shading angle=32.893] (0,0) rectangle (4,1);

The solution is to perform scaling before rotation, which only requires to modify the computation of the scaling factor. If the dimensions of the bounding box are (w,h) and the shading angle is α then
xscale = .01992528 * (w*|cos(α)|+h*|sin(α)|)/(|cos(α)|+|sin(α)|)
yscale = .01992528 * (h*|cos(α)|+w*|sin(α)|)/(|cos(α)|+|sin(α)|)
instead of
xscale = .01992528 * w
yscale = .01992528 * h

This does not not change the result in basic situations, i.e. when the bounding box is a square or the shading angle is a multiple of 90°, and gives a correct shading angle in all cases.

Perhaps should it be also considered to change the place where \pgf@shade@extra@transform is applied. It is currently applied last which makes it actually the first transformation of the shading.
Sorry for the huge images in my ticket. I was unable to edit the ticket and replace them. Also, the patch was missing and I was unable to add it afterwards. Here it is.
Last edit: Eric Domenjoud 2019-02-18
Fixed in https://sourceforge.net/p/pgf/git/ci/273ae3f82cfeddcff1e2c66798471badfb1acd02/
Thank you for contributing patches, but could you please always put only one statement per line?
I'm still glad to contribute. If I happen to submit another patch, I will format my code more carefully.
By the way, do you have any Idea why I was able neither to edit my ticket nor to change the attached files?
That is because Sourceforge is total garbage. For example I don't receive emails anymore from Sourceforge since I messed around with the default settings. I want to migrate PGF to GitHub or GitLab but currently I am waiting for feedback from Till on that. I don't want to be too hasty with that and disregard his opinion (if he ever replies). There is no fixed deadline from my side yet.
Ok. I wondered whether I did something wrong.