...the story of the rich young rule[r]...
Jesus is obliging the man with the answer he wishes to hear. IOW Jesus is giving a fool's answer to a fool's question and demand. If one could possess eternal life by keeping the commandments, why oh why didn't he leave with a joyful heart. Jesus didn't contradict the man's testimony. ...
The 'Rich Young Ruler' was actually not keeping the Commandments fully, please notice:
And, behold, one came and said unto him, Good Master, what good thing shall I do, that I may have eternal life? Matthew 19:16
And he said unto him, Why callest thou me good? [there is] none good but one, [that is], God: but if thou wilt enter into life, keep the commandments. Matthew 19:17
He saith unto him, Which? Jesus said, Thou shalt do no murder, Thou shalt not commit adultery, Thou shalt not steal, Thou shalt not bear false witness, Matthew 19:18
Honour thy father and [thy] mother: and, Thou shalt love thy neighbour as thyself. Matthew 19:19
The young man saith unto him, All these things have I kept from my youth up: what lack I yet? Matthew 19:20
Jesus said unto him, If thou wilt be perfect, go [and] sell that thou hast, and give to the poor, and thou shalt have treasure in heaven: and come [and] follow me. Matthew 19:21
But when the young man heard that saying, he went away sorrowful: for he had great possessions. Matthew 19:22
See also Mark 10:17-30; Luke 18:18-23...
...which specific commandments was Jesus directly quoting from? The Ten Commandments, namely the 'second Table', dealing with Love of/to neighbour [Leviticus 19:-17-18], the horizontal relationship [man-to-man, one to another], as found here: Exodus 20:12-16...
...but notice, that there is one commandment which Jesus did not directly cite, found in Exodus 20:17...
...the one dealing with covetousness; the Tenth Commandment. Why?
Because the 'Rich Young Ruler' when asked to sell what he had and 'give' [being the antithesis to covetousness] to the poor and come and follow Jesus, would not do it. Therefore, he transgresses all of the commandments [even as James says], for his treasure [his mammon] was his Idol.
There is no 'fool's question' here, for the 'Rich Young Ruler' truly sought the answer to his question from Jesus, but when Jesus, by an indirect route placed His finger upon the point in the man's heart, the man refused to yield, and went on his way sorrowful, a slave to riches, and away from the one who offered him joy and freedom in Himself [Christ Jesus].