Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first line in method and class #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/saikuro/html_stylesheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def HTMLStyleSheet.style_sheet
out.puts ' margin: 0;'
out.puts '}'
out.puts ''
out.puts '.class_total_complexity, .class_total_lines, .start_token_count, .file_count {'
out.puts '.class_total_complexity, .class_total_lines, .start_token_count, .file_count, .class_first_line {'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [112/80]

out.puts ' font-size: 13px;'
out.puts ' font-weight: bold;'
out.puts '}'
out.puts ''
out.puts '.class_total_complexity, .class_total_lines {'
out.puts '.class_total_complexity, .class_total_lines, .class_first_line {'
out.puts ' color: #c00;'
out.puts '}'
out.puts ''
Expand Down
3 changes: 2 additions & 1 deletion lib/saikuro/parse_class.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class ParseClass < EndableParseState
def initialize(lexer,parent=nil)
super(lexer,parent)
@first_line = lexer.line_no
@type_name = "Class"
end

Expand All @@ -15,7 +16,7 @@ def compute_state(formater)
child.kind_of?(ParseClass)
end

formater.start_class_compute_state(@type_name,@name,self.calc_complexity,self.calc_lines)
formater.start_class_compute_state(@type_name,@name,self.calc_complexity,@first_line,self.calc_lines)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [105/80]
Redundant self detected.
Space missing after comma.

super(formater)
formater.end_class_compute_state(@name)

Expand Down
3 changes: 2 additions & 1 deletion lib/saikuro/parse_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class ParseDef < EndableParseState

def initialize(lexer,parent=nil)
super(lexer,parent)
@first_line = lexer.line_no
@complexity = 1
@looking_for_name = true
@first_space = true
Expand Down Expand Up @@ -53,7 +54,7 @@ def parse_token(token)
end

def compute_state(formater)
formater.def_compute_state(@name, self.calc_complexity, self.calc_lines)
formater.def_compute_state(@name, self.calc_complexity, @first_line, self.calc_lines)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [89/80]
Redundant self detected.

super(formater)
end
end
2 changes: 1 addition & 1 deletion lib/saikuro/parse_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def compute_state_for_global(formater)
return if global_def.empty?
gx = global_def.inject(0) { |c,s| s.calc_complexity }
gl = global_def.inject(0) { |c,s| s.calc_lines }
formater.start_class_compute_state("Global", "", gx, gl)
formater.start_class_compute_state("Global", "", gx, 0, gl)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single-quoted strings when you don't need string interpolation or special symbols.

global_def.each do |s|
s.compute_state(formater)
end
Expand Down
8 changes: 4 additions & 4 deletions lib/saikuro/parse_state_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ def start(new_out=nil)
def end
end

def start_class_compute_state(type_name,name,complexity,lines)
def start_class_compute_state(type_name,name,complexity,first_line,lines)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after comma.

@current = name
@out.puts "-- START #{name} --"
@out.puts "Type:#{type_name} Name:#{name} Complexity:#{complexity} Lines:#{lines}"
@out.puts "Type:#{type_name} Name:#{name} Complexity:#{complexity} FirstLine:#{first_line} Lines:#{lines}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [110/80]

end

def end_class_compute_state(name)
@out.puts "-- END #{name} --"
end

def def_compute_state(name,complexity,lines)
def def_compute_state(name,complexity,first_line,lines)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after comma.

return if @filter.ignore?(complexity)
warn_error?(complexity, name)
@out.puts "Type:Def Name:#{name} Complexity:#{complexity} Lines:#{lines}"
@out.puts "Type:Def Name:#{name} Complexity:#{complexity} FirstLine:#{first_line} Lines:#{lines}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [101/80]

end

end
9 changes: 5 additions & 4 deletions lib/saikuro/state_html_complexity_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,26 @@ def end
@out.puts "</html>"
end

def start_class_compute_state(type_name,name,complexity,lines)
def start_class_compute_state(type_name,name,complexity,first_line,lines)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after comma.

@current = name
@out.puts "<div class=\"class_complexity\">"
@out.puts "<h2 class=\"class_name\">#{type_name} : #{name}</h2>"
@out.puts "<div class=\"class_first_line\">First Line: #{first_line}</div>"
@out.puts "<div class=\"class_total_complexity\">Total Complexity: #{complexity}</div>"
@out.puts "<div class=\"class_total_lines\">Total Lines: #{lines}</div>"
@out.puts "<table width=\"100%\" border=\"1\">"
@out.puts "<tr><th>Method</th><th>Complexity</th><th># Lines</th></tr>"
@out.puts "<tr><th>Method</th><th>Complexity</th><th>First Line</th><th># Lines</th></tr>"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [94/80]
Prefer single-quoted strings when you don't need string interpolation or special symbols.

end

def end_class_compute_state(name)
@out.puts "</table>"
@out.puts "</div>"
end

def def_compute_state(name, complexity, lines)
def def_compute_state(name, complexity, first_line, lines)
return if @filter.ignore?(complexity)
klass = warn_error?(complexity, name)
@out.puts "<tr><td>#{name}</td><td#{klass}>#{complexity}</td><td>#{lines}</td></tr>"
@out.puts "<tr><td>#{name}</td><td#{klass}>#{complexity}</td><td>#{first_line}</td><td>#{lines}</td></tr>"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [110/80]

end

end