Introducing LAMS, a LookML style guide and linter

  • 28 January 2019
  • 4 replies
  • 2664 views

Userlevel 6
Badge

The Problem

 

A frequently asked question by those that develop in Looker is around how to write code that is reusable, self-explanatory and reliable. This is often because they have been working on the same model for a significant period of time, very often with multiple contributors, and it has become bloated and very hard to maintain and build upon.

 

 

The Why

 

 

Look At Me Sideways (LAMS) seeks to address this problem by:

 

  1. Helping developer teams adhere to best practices
  2. Aiding anyone interested in cleaning and refactoring their LookML model
  3. Ensuring consistency and a certain level of code quality
  4. Automating the pull request review process for those that enforce them
  5. Maintaining a clean master branch at all times

 

 

The How

 

 

LAMS is a linter and a style guide that picks up and flags anti-patterns or anything that deviates from recommended LookML constructs. It also explains exactly what’s wrong as well as provides common best-practice solutions and/or alternatives. The style guide itself is intended to evolve over time as new conventions are identified, suggested and/or potentially contributed by the community it supports.

 

 

In order to get the most of out it, it is recommended to run it in your CI environment. When set up like this, the workflow involves four steps. It all starts when a developer commits new code from the Looker IDE (Step 1). GitHub then sends off a webhook to the server hosting LAMS asking it to check the new code (Step 2). Once LAMS does this, it adds the result files to the trigger branch (Step 3) and the user will be prompted to pull the files from his remote branch (Step 4). The entire process takes a few seconds at most and is entirely seamless, providing everything that the developer needs from within the platform.

 

 

 

 

WUzCNYc2_0_pxwdw2lsSw8WJ621U4UEQNYaCPBzimUGypQs0db4YR1e_fbxJYeDeIhzST0gETkUkeyQqxGBucnZRo4qS6l-u2vKPAwie5mSzHbaMGHHxadTalotfiYeZdaOj7CE4

 


See a video of LAMS in action:

LAMS video

https://vimeo.com/313492643/30c4e0175c

 

 

 

The Setup

 

 

LAMS can be installed either as a standalone npm package using these instructions or deployed in your CI environment. The latter is highly recommended but since it can be quite an involved process, we are also shipping it with a dockerized version that contains a fully functional Jenkins server with a pre-configured job. This will allow you to get setup in just a few minutes and hit the ground running. If you want to contribute to the project, check it out on github.

 

 

LAMS is developed and maintained by Fabio Beltramini (aka @fabio) and Joseph Axisa (aka @jax)

 


4 replies

Hi @fabio,

Please help me with the syntax to implement multiple exceptions in manifest file.

I have tried two different syntaxes, but I get parsing errors for them as mentioned below.

 

Syntax 1:

# LAMS
# rule_exemptions: {
#  F2: "Rule not Required"
# }
# LAMS
# rule_exemptions: {
#  F3: "Rule not Required"
# }

Error:

{
    error: {
      toString: [Function: toString],
      message: 'Expected "#", ":", or [ \\t\\n\\r] but "r" found.',
      expected: [Array],
      found: 'r',
      location: [Object],
      name: 'SyntaxError',
      context: '3:\t  F2: "Rule not Required"\n' +
        '4:\t }\n' +
        '5:\t LAMS\n' +
        '6:\t rule_exemptions: {\n' +
        '7:\t  F3: "Rule not Required"\n' +
        '8:\t }'
    },
    _file_path: 'manifest.lkml',
    _file_rel: '',
    _file_name: '',
    _file_type: 'manifest'
  },

 

 

Syntax 2:

# LAMS
# rule_exemptions: {
#  F2, F3 "Rule not Required"
# }

 

Error:

{
    error: {
      toString: [Function: toString],
      message: 'Expected "#", ":", [ \\t\\n\\r], or [\\-+_a-zA-Z0-9.] but "," found.',
      expected: [Array],
      found: ',',
      location: [Object],
      name: 'SyntaxError',
      context: ''
    },
    _file_path: 'manifest.lkml',
    _file_rel: '',
    _file_name: '',
    _file_type: 'manifest'
  },

 

 

Please let me know the right way to implement multiple exceptions in a manifest file

Userlevel 6
Badge

Hi @lokhandepriyanka0201-162400869 , thanks for the question :) 

 

Please help me with the syntax to implement multiple exceptions in manifest file.

 

# LAMS
# rule_exemptions: {
# F2: "Reason for F2"
# F3: "Reason for F3"
# }

 

Thanks @fabio , That helped me

Hi @fabio ,

Is there a way while implementing LAMS, we can exclude a particular folder from Looker project that won’t be checked for LAMS rules.

 

Reply