ooyala / barkeep

The friendly code review system.
getbarkeep.org
1.42k stars 145 forks source link

Fixing error: NoMethodError - undefined method `gsub' for nil:NilClass #444

Closed squaresurf closed 8 years ago

squaresurf commented 11 years ago

I was getting an error in lib/syntax_highlighter.rb where

SyntaxHighlighter.pygmentize(file_type, blob.data)

was returning nil and thus throwing an error in

def self.global_highlighting(pygmentized_text)

when it tried to call the gsub method on the nil object.

I'm primarily a PHP developer so please feel free to school me on Ruby methodologies that I may have screwed up.

plagi commented 10 years ago

+1

squaresurf commented 9 years ago

ping

dmac commented 9 years ago

Hi @squaresurf, thanks for the PR. I think a more thorough solution would be to investigate how pygmentized_text could be nil in the first place. There might be a deeper problem for which this only treats one symptom.

squaresurf commented 9 years ago

That seems like a good idea, but I haven't used this project in a long time so I'm not a good candidate for digging deeper as I don't have a server running at the moment.

@plagi do you have a way to repro and dig into this deeper to find out why pygmentized_text could be nil?

I do agree that it would be good to follow this further up, yet this PR does fix the issue so that barkeep is useful. After I patched it with this, then barkeep worked like a charm and I didn't experience anymore oddities. If you're sure you'd rather dig deeper than merge this, then feel free to close this PR.

squaresurf commented 8 years ago

I'm closing this as the PR is stale. Feel free to merge if you'd like :smile: