Skip to content

Commit

Permalink
Merge pull request #1173 from openSUSE/hellcp/haml-lint
Browse files Browse the repository at this point in the history
Add a linter for haml
  • Loading branch information
hennevogel authored Mar 30, 2022
2 parents 11d6497 + 760c810 commit c5f6df5
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 49 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ jobs:
bundler-cache: true
- name: Run linter
run: bundle exec rubocop
haml-linter:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Run linter
run: bundle exec haml-lint app/views/
unit:
needs: linter
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ group :test do
gem 'capybara'
gem 'faker'
gem 'geckodriver-bin', '~> 0.28.0'
gem 'haml_lint', require: false
gem 'rubocop'
gem 'rubocop-minitest'
gem 'rubocop-performance'
Expand Down
10 changes: 9 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ GEM
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 5.1)
haml_lint (0.40.0)
haml (>= 4.0, < 5.3)
parallel (~> 1.10)
rainbow
rubocop (>= 0.50.0)
sysexits (~> 1.1)
hashdiff (1.0.1)
hashie (5.0.0)
html2haml (2.2.0)
Expand Down Expand Up @@ -284,7 +290,6 @@ GEM
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2)
sexp_processor (4.16.0)
sentry-rails (5.1.1)
railties (>= 5.0)
sentry-ruby-core (~> 5.1.1)
Expand All @@ -293,6 +298,7 @@ GEM
sentry-ruby-core (= 5.1.1)
sentry-ruby-core (5.1.1)
concurrent-ruby
sexp_processor (4.16.0)
singleton (0.1.1)
sprockets (4.0.3)
concurrent-ruby (~> 1.0)
Expand All @@ -302,6 +308,7 @@ GEM
activesupport (>= 5.2)
sprockets (>= 3.0.0)
strscan (3.0.1)
sysexits (1.2.0)
temple (0.8.2)
terser (1.1.8)
execjs (>= 0.3.0, < 3)
Expand Down Expand Up @@ -341,6 +348,7 @@ DEPENDENCIES
gettext (>= 1.9.3)
gettext_i18n_rails (>= 0.4.3)
haml-rails (~> 2.0)
haml_lint
hashie
lograge
matrix
Expand Down
28 changes: 16 additions & 12 deletions app/views/layouts/_flash.html.haml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
- unless flash.blank?
#flash-messages.container
- %w(success error warn note notice info).each do |flash_type|
- if (flash[flash_type] && !flash[flash_type].empty?)
- flash_header = case flash_type.to_sym
- when :error then 'alert alert-danger'
- when :warn then 'alert alert-warning'
- when :success then 'alert alert-success'
- when :note then 'alert alert-light'
- when :info then 'alert alert-info'
- when :notice then 'alert alert-primary'
.container#flash-messages
- %w[success error warn note notice info].each do |flash_type|
- if flash[flash_type] && !flash[flash_type].empty?
:ruby
states = {
error: 'alert alert-danger',
warn: 'alert alert-warning',
success: 'alert alert-success',
note: 'alert alert-light',
info: 'alert alert-info',
notice: 'alert alert-primary'
}
flash_header = states[flash_type.to_sym]

- body = flash[flash_type].gsub(/\n/, '<br/>')
- body = sanitize body, :tags => %w(a b p ul li br u), :attributes => %w(href title)
body = flash[flash_type].gsub(/\n/, '<br/>')
body = sanitize body, tags: %w[a b p ul li br u],
attributes: %w[href title]

%div{ class: flash_header }
%p
Expand Down
8 changes: 5 additions & 3 deletions app/views/layouts/_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
.footer-copyright
&copy; 2011&ndash;
= Time.new.year
= _("openSUSE contributors")
= _('openSUSE contributors')
.list-inline
= link_to _("Source Code"), "https://github.com/openSUSE/news-o-o", class: "list-inline-item"
= link_to _("License"), "https://github.com/openSUSE/news-o-o/blob/master/LICENSE", class: "list-inline-item"
- github_link = 'https://github.com/openSUSE/software-o-o'
= link_to _('Source Code'), github_link, class: 'list-inline-item'
= link_to _('License'), "#{github_link}/blob/master/LICENSE",
class: 'list-inline-item'
39 changes: 24 additions & 15 deletions app/views/layouts/_navbar.html.haml
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
%nav.navbar.noprint.navbar-expand-md.sticky-top
- homepage = build_service == true ? "https://build.opensuse.org" : "/"
= link_to homepage, class: "navbar-brand" do
= image_tag "chameleon/logo/favicon.svg", class: "d-inline-block align-top", alt: "openSUSE", title: "openSUSE", width: "30", height: "30"
- homepage = build_service == true ? 'https://build.opensuse.org' : '/'
= link_to homepage, class: 'navbar-brand' do
= image_tag 'chameleon/logo/favicon.svg', class: 'd-inline-block align-top',
alt: 'openSUSE', title: 'openSUSE', width: '30', height: '30'
.navbar-title
- if build_service == true
= _("Build Service")
= _('Build Service')
- else
= _("Software")
= _('Software')

%button.navbar-toggler{ type: "button", data: { toggle: "collapse", target: "#navbar-collapse" } }
= icon "navbar_toggle"
%button.navbar-toggler{ type: 'button', data: { toggle: 'collapse',
target: '#navbar-collapse' } }
= icon 'navbar_toggle'

.collapse.navbar-collapse#navbar-collapse
%ul.nav.navbar-nav.mr-auto.flex-md-shrink-0
- if build_service == true
%li.nav-item
= link_to "Embed instructions", { controller: "download", action: "doc" }, class: "nav-link"
= link_to 'Embed instructions', { controller: 'download',
action: 'doc' }, class: 'nav-link'
%li.nav-item.dropdown
= link_to "#", class: "nav-link dropdown-toggle", id: "locale-menu-link", role: "button", "data-toggle": "dropdown", "aria": { "haspopup": "true", "expanded": "false" } do
= icon "navbar_locale"
%span.selected-language= LANGUAGE_NAMES[@lang]
= link_to '#', class: 'nav-link dropdown-toggle',
id: 'locale-menu-link', role: 'button',
'data-toggle': 'dropdown', aria: { haspopup: 'true',
expanded: 'false' } do
= icon 'navbar_locale'
%span.selected-language= LANGUAGE_NAMES[current_language]
%span.caret
.dropdown-menu.dropdown-menu-right
- LANGUAGES.sort.each do |lang|
= link_to LANGUAGE_NAMES[lang], params.permit.merge(locale: lang), class: "dropdown-item"
= link_to LANGUAGE_NAMES[lang], params.permit.merge(locale: lang),
class: 'dropdown-item'

%button.navbar-toggler.megamenu-toggler{ type: "button", data: { toggle: "collapse", target: "#megamenu" } }
= icon "megamenu_toggle"
%button.navbar-toggler.megamenu-toggler{ type: 'button',
data: { toggle: 'collapse',
target: '#megamenu' } }
= icon 'megamenu_toggle'

#megamenu.megamenu.collapse
.megamenu.collapse#megamenu
38 changes: 22 additions & 16 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
!!! 5
%html
%head{ lang: @lang }
%meta{ charset: "utf-8" }
%meta{ "http-equiv": "X-UA-Compatible", content: "IE=edge" }
%meta{ name: "viewport", content: "width=device-width, initial-scale=1" }
%meta{ charset: 'utf-8' }
%meta{ 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' }
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
%title= @page_title || _('openSUSE Software')
%meta{ "http-equiv": "Content-Type", content: "text/html; charset=utf-8" }
%meta{ "http-equiv": "Content-Script-Type", content: "text/javascript" }
%meta{ "http-equiv": "Content-Style-Type", content: "text/css" }
%meta{ 'http-equiv': 'Content-Type', content: 'text/html; charset=utf-8' }
%meta{ 'http-equiv': 'Content-Script-Type', content: 'text/javascript' }
%meta{ 'http-equiv': 'Content-Style-Type', content: 'text/css' }

%link{ rel: "search", type: "application/opensearchdescription+xml", title: "openSUSE Software", href: "/search_software.xml" }
%link{ href: "https://software.opensuse.org/favicon.ico", rel: "shortcut icon" }
%link{ rel: 'search', type: 'application/opensearchdescription+xml',
title: 'openSUSE Software', href: '/search_software.xml' }
%link{ href: 'https://software.opensuse.org/favicon.ico',
rel: 'shortcut icon' }

= stylesheet_link_tag "application"
= javascript_include_tag "application"
= stylesheet_link_tag 'application'
= javascript_include_tag 'application'
%body
= render partial: "layouts/navbar", locals: { hidesearchbox: @hide_search_box, build_service: @build_service }
= render partial: 'layouts/navbar',
locals: { hidesearchbox: @hide_search_box,
build_service: @build_service,
current_language: @lang }

- unless flash.blank?
= render(partial: "layouts/flash", object: flash)
= render(partial: 'layouts/flash', object: flash)

%main#content.page-content.flex-fill
%main.page-content.flex-fill#content
- unless @hide_search_box
= render partial: 'search/find_form', locals: { baseproject: @baseproject }
= render partial: 'search/find_form',
locals: { baseproject: @baseproject }

#search_result_container
#search-result-container
= yield

= render partial: "layouts/footer"
= render partial: 'layouts/footer'
4 changes: 2 additions & 2 deletions app/views/layouts/application.iframe.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
!!! 5
%html
%head
= stylesheet_link_tag "application"
= javascript_include_tag "application"
= stylesheet_link_tag 'application'
= javascript_include_tag 'application'

%body
= yield
Binary file added vendor/cache/haml_lint-0.40.0.gem
Binary file not shown.
Binary file added vendor/cache/sysexits-1.2.0.gem
Binary file not shown.

0 comments on commit c5f6df5

Please sign in to comment.