Hard piped connection to water heater with anode rod on outlet
I can't imagine a code that would prohibit flexible water lines, but all building codes are up to the local jurisdiction so it is possible.  In earthquake country on the west coast, flexible water lines are required in some places and optional but recommended in others.

Looking at, for example, Daly City water heater requirements (http://www.dalycity.org/Page192.aspx) say flex lines are recommended but not mandatory.  In either case, "A union or flared connection is required on hot and cold water lines to facilitate removal of the appliance (CPC 609.5)".   Flex lines give you the flare connection.  

There are two common types of flexible lines for water heaters: copper and rubber+steel.  It could be that in your jurisdiction, one type is allowed but the other is prohibited.



A union is a pipe joint with matching threads, made specifically for allowing disconnection of a hard connection.  Whoever installed yours without a union didn't know what they were doing.  You can easily add a PVC union to the existing setup if you want to avoid adding a flex line for any reason.



But personally, I would install the copper flex lines on both hot and cold, until a local inspector told me specifically it was not allowed.

And while you're at it, if this is a gas heater, make sure it is 18 inches off the floor too.  :-)