The grams of sugar doesn't distinguish between those that are naturally occurring and those that are refined. Looking at the ingredient list is more informative. FDA labeling laws require that all ingredients be listed in order of the quantity used. If refined sugars are the first or second ingredient, it is not a good choice. The refined sugars, Sucrose, corn syrup, high fructose corn syrup and chocolate are frequently found high on the list.
Many bars are nothing more than ordinary candy bars with protein powder added in.
Another ingredient to be on the lookout for is saturated fat. The total fat grams, however, is not as important as the type of fat used. Some bars derive their fat from peanut butter, which is fine in small amounts. Unfortunately, others use hydrogenated oils and tropical oils such as coconut oil or palm kernel oil. When choosing a bar you should also look at the total calories and the carb to protein ratio.