Costco (COST -1.51%) is a perennial favorite among investors including Charlie Munger, Warren Buffett's partner since 1978. But after handily beating the S&P 500 during 2018, Costco sold off hard after its recent earnings report, halving its gains for the year. As of this writing, the stock is up roughly 11% for the year.

COST Year to Date Price Returns (Daily) Chart

COST Year to Date Price Returns (Daily) data by YCharts.

One great way to make money in the stock market is to buy high-quality companies when they go on sale due to a bad quarter or two. Does Costco fall into this camp?

What happened last quarter?

Even though investors pushed Costco's stock down, its earnings report revealed some impressive numbers. Same-store sales clocked in at 7.5%, adjusted for changes in gasoline prices, foreign exchange, and accounting changes. That's really impressive compared to its retail peers. The company's newer e-commerce offering also increased a respectable 26.2% year over year.

Another big positive: The company's all-important membership metrics remain healthy and growing. Total memberships were up 600,000, from 51.6 million members to 52.2 million members, while total cardholders grew from 94.3 million to 95.4 million. Executive memberships -- $120 a year --  grew by 442,000 to 19.7 million members. Importantly, the U.S. and Canada membership renewal rate ticked up to 90.5%, up from 90.4% last quarter, with the global renewal rate increasing to 88% from 87.9% the previous quarter. Since Costco earns most of its profits from membership fees, this means the underlying business is healthy.

A wide view of the inside of a warehouse superstore

Image source: Getty Images.

Investors, however, may have been turned off by Costco's rising costs, which were affected by rising merchandise costs, higher wages, and increased rewards for holders of the company's new Citi/Visa card. These costs compressed gross margin by 50 basis points, from 11.25% to 10.75% (though excluding gas and other items, gross margin was only down 26 basis points). Overall, these factors pushed operating income down $2 million from last year's figure, from $951 million to $949 million. This surprise decrease in operating income was the likely culprit for the sell-off.

Is Costco a value?

If you believe that Costco's top-notch management can get past the current cost pressures, are Costco shares now a good buy? Are shares sufficiently cheap?

That all depends on the definition of "cheap." Certainly, the company's current price-to-earnings ratio of 28 and forward P/E ratio of 26.8 aren't "cheap" by the standards of the overall market -- the S&P 500 currently has a P/E of 21 and forward P/E of 16.

Furthermore, Costco's drop has really only put its valuation in line with recent historical averages, as the stock had been bid up to a premium during the first half of the year:

COST PE Ratio (TTM) Chart

COST PE Ratio (TTM) data by YCharts.

In that light, I can't really say that Costco is an especially cheap stock right now.

A great company at a fair price

However, while Costco's valuation still isn't particularly cheap at the moment, I do think today could be a compelling entry point for those who like buying safe, high-quality businesses at reasonable prices for the long term.

This is especially true in an increasingly uncertain investing environment. As trade wars and political intrigue continue to dominate headlines, Costco's consistency and top-notch business model should command a premium. Look at the consistency in Costco's financial metrics over the past 10 years:

COST Revenue (Annual) Chart

COST Revenue (Annual) data by YCharts.

In an uncertain world, people will still continue to buy household goods, fresh food, and other staples that Costco sells. Furthermore, people always love bargains, and Costco's policy of passing cost savings on to customers should continue to resonate in good times and bad. Despite intense competition in the retail market, Costco has managed to grow memberships by serving its customers and employees well.

To sum up, Costco is a relatively safe, high-quality stock in an uncertain market, and is currently valued more or less in line with its historical averages.

For the long-term investor who likes steady companies that pay out dividends (and occasionally supplements those with large special dividends every few years), Costco could be a good purchase at these levels. I wouldn't necessarily count on any home-run gains in the near term, but if you have a long-term buy-and-hold mentality, you could do far worse than getting into the stock today.