Image source: Getty Images.

With the unrelenting rise of e-commerce putting an increasing amount of pressure on traditional retailers, there are plenty of retail stocks that are best avoided. Some are obvious: Sears is a trainwreck no matter how you slice it. There are some retail stocks that appear to be solid investments on the surface but ultimately come with major downsides. Costco (COST -0.12%) and GameStop (GME 2.56%) are two prime examples.

On the flip side, Wal-Mart (WMT 0.57%) doesn't get the credit it deserves. The company may be the quintessential brick-and-mortar retailer, but it's been making some aggressive moves to better compete in a world where e-commerce can no longer be ignored.

Why you should avoid Costco stock

Costco is a great company, but even the best company bought at too high of a price can make for a lousy investment. The numbers speak for themselves: Costco earned $5.33 per share in fiscal 2016, putting the price-to-earnings ratio at a stratospheric 28. Growth is consistent but slow, with analysts expecting mid-single-digit revenue growth this year and next.

Image source: Costco.

Costco stock certainly deserves a premium based on the quality of the company, but I think we've reached the point where that premium is excessive. This doesn't mean that the stock price is going to collapse, but I suspect that returns from here will be depressed. Costco stock soared 81% over the past five years. Given the current valuation, I suspect that the next five years won't be nearly as impressive.

Beyond valuation, Costco has been extremely slow to embrace e-commerce. This hasn't been much of a problem thus far, as the warehouse club model protects the company to a degree from online retailers. But Costco is going to eventually need to embrace e-commerce and make it work with its fleet of stores. Combine this long-term uncertainty around e-commerce with an inflated valuation and you get a retail stock that doesn't look like a great investment.

Why you should avoid GameStop stock

GameStop stock looks incredible cheap, trading for a single-digit multiple of earnings. The company has been diversifying beyond selling physical games, opening and acquiring stores that sell used electronics and mobile devices and increasing its focus on selling digital games. Diversification is a fine strategy, and it's the right move for the company. But there's a time bomb built into GameStop's business model that makes it a stock to avoid.

Image source: GameStop.

GameStop makes a killing from buying and selling used games. In fiscal 2015, pre-owned video game products accounted for 38% of the company's gross profit and carried a gross margin of nearly 47%, nearly twice the gross margin of new video game products. Used games are a cash cow for the company. Unfortunately for GameStop, the age of physical disks will eventually come to an end when game consoles inevitably go all digital. When that happens, the new game business will disappear, and the used-game business, while likely lingering due to previous-generation games, will quickly become far less lucrative for the company.

GameStop is going to look a lot different 10 years from now, or even five years from now, compared to today. A bargain valuation doesn't mean much if the main drivers of earnings are likely to disappear. It's impossible to predict how profitable the GameStop of the future will be, and that's a good reason to sit this one out.

Why Wal-Mart is a stock to buy

Wal-Mart's earnings are currently depressed thanks to the company's various initiatives, including wage hikes, increased employee training, and e-commerce. Wal-Mart expects to produce adjusted earnings per share between $4.15 and $4.35 in both fiscal 2017 and fiscal 2018, down from $4.59 in fiscal 2016.

Image source: Wal-Mart.

The investments that Wal-Mart is making, though, are important. First, the company is trying to improve the customer experience in its stores, raising wages, bringing back greeters, and making it easier for employees to climb the ladder into management positions. The results so far have been encouraging, with U.S. comparable sales consistently growing and customer satisfaction on the rise.

On the e-commerce front, Wal-Mart is going big. The company recently acquired Jet.com for over $3 billion, giving it a brand that could help the company appeal to younger customers. Online grocery pickup is a major initiative, allowing customers to order groceries online and have them carried out to their car for no extra charge. And ShippingPass, the $49 annual membership that provides free two-day shipping, is an effort to compete head-on with Amazon Prime.

Retailers that fail to adapt to changing consumer preferences are going to be left behind. Wal-Mart is taking aggressive steps to ensure that it can continue to thrive in a world where e-commerce is becoming increasingly important. With the stock trading for around 16 times earnings guidance, Wal-Mart looks like a solid long-term investment.