Static Code Analysis & Phabricator’s Arcanist

Code Reviews

Writing code is a tedious process as it involves many conditions. Often the programmers miss out scenarios which can result in bugs (rainy day scenarios). Another common scenario missed out is optimizing the code for space and time complexity (efficiency). The programmers will be busy trying to address the problem at hand and many a times they miss on optimizing.

When we have Peer code reviews, this can be improved. Having few issues with the code is fine but not having code reviews is not acceptable in any software development team.

Static Code Analysis

In simple terms this method is to assess the behavior of the code by performing lexical, syntax analysis as well as other advanced means. Control flow & Data flow analysis are also performed. Findbugs for Java is to a well established example.

Security considerations are one of the major aspects that static code analysis often targets. OWASP wiki entry on static code analysis is an excellent starting point to learn more.

Linting

Some of the basic static code analyzers are called Linters. Though there is no hard and fast rule to call a certain code analyzer as linting tool I think its safe to assume that the coding standard checkers can be called as a linting tool. The term is originated from a static code analyzer called “Lint”.

Code Review tools

The process of code review is quite tedious and as the complexity of the project increases, this gets tougher. There are numerous tools that helps developers to conduct effective code reviews. With the advent of Continuous Integration, its lot more easier to incorporate code review in an automated fashion. Once the automatic code review is done, its essential to report the issues in a easily addressable way.

New generation Project management and Source Control Management Software like Gitlab integrates automation of the review, CI and CD in an innovative manner.

A Gitlab repository which is a CI + CD back end for a Github project.

In addition to the modern all-in-one platforms, there are obviously tools like Reviewboard and others which is focused on the code review alone.

Review Board an excellent, dedicated code review tool.

Phabricator

Meet Phabricator – an excellent project management & source code management platform. The platform has a powerful CLI interface which makes it the swiss army knife of Software Development Process.

Well, I have not heard about it, who uses it ?

Honestly this is the most frequent comment I have heard about Phabricator. So here is a list of users:

  • Wikimedia Foundation – yea, that small website guys!
  • Facebook
  • Asana.com
  • Blender (https://developer.blender.org/)
  • KDE
  • then of-course, yours faithfully!

I rest my case.

In my opinion, Phabricator is the best project management and source hosting platform existing with its unique code review features, CLI tools etc. When it comes to CI and CD, phabricator is not the best and with tools like Gitlab and we just have to mirror Phabricator hosted repository and take care of the CI and CD. Needless to say, Phabricator also supports Subversion and Mercurial. Since they provide a powerful programmable API, it may be even possible to integrate with other code management solutions like Preforce.

Arcanist

This section is about arcanist & is intended for users who are new to it or know about it but haven’t set it up anytime.

Arcanist aka arc is the command line tool which is provided by Phabricator to help with code reviews, merging etc. In a nutshell, we can raise a code review, with pre-defined static code analysis and rules using this powerful tool.


There are four sections of this article:

  • What is it?
  • Which features can we use?
  • Why should we bother?
  • Quick start guide

What is it ?
Arcanist basically works on top of tools like Git, Differential, Linter etc and provides command line interface to them. It is a code review and revision management utility.

Which features can we use ?

  • lint
  • diff
  • land
  • anoid

Why Should we bother ?

Lint: Wouldn’t it be nice if someone could look into your code and point out syntax errors, wrong use of constructs, use of undeclared variable and many more ? It turns out that there are tools which do this exact work and are referred to as Lint. It also simplifies code review process for the reviewer as well as the author

Diff: Working on a project and not sure whether the changes made are ready to be pushed? This is where diff comes into play. If using Git, arc diff sends all commits in a range for review. By default, this range is

git merge-base origin/master HEAD..HEAD

Land: If the review raised through gets accepted, then we use arc land to publish the changes.

Quick Start Guide

Supported on: Linux, Mac OS X, Windows, FreeBSD & there is a quick way to setup anywhere with NixOS.

The one liner install on macOS and Linuxes using the awesome Nix package manager :

sudo mkdir /nix ; sudo chown -R  $LOGNAME /nix; bash <(curl https://nixos.org/nix/install) ; nix-shell -p arcanist

The manual, old school, Installation:

  1. mkdir ~/phabricator && cd ~/phabricator
  2. git clone https://github.com/phacility/libphutil.git
  3. git clone https://github.com/phacility/arcanist.git
  4. Add ~/phabricator/arcanist/bin to your PATH environment variable

Example:
export PATH=”/home/user/phabricator/arcanist/bin:$PATH”

  1. Try typing ‘arc’, if it shows usage exception, then we are good so far.
  2. To set up tab completion add the following to you PATH environment variable source /path/to/arcanist/resources/shell/bash-completion
    Example:-
    source /home/user/phabricator/arcanist/resources/shell/bash-completion

Configuring arc for a project :

This section assumes that you have a Phabricator installation at https://phabricator.steem.io

  1. Goto project directory
  2. Create a file with name ‘.arcconfig’ (without quotes)
  3. Paste the following in the file.
    {"phabricator.uri" : "https://phabricator.steem.io"}
  4. Run
    arc install-certificate and follow the instructions.

The commands could be used in this sequence:


arc lint –> arc diff –> arc land

arc lint

Setting up lint :


1. Create a file with name ‘.arclint’ in project directory
2. Detailed documentation for setting up .arclint can be found here.

Example of .arclint file:-
{
“linters”: {
“lint”: {
“type”: “pep8”,
“include”: “(\.py$)”
}
}
}
“lint” –> this is a custom name given by you, it doesn’t affect anything.
“type” –> to specify the linter we would like to use.
“include” –> regex for the format of files to lint.
“exclude” –> can be used to exclude files matching include tag in specific directories.

arc diff

  • First time while using this command, it will ask for access token which can be obtained by following the instructions.
  • Specify Test plan, reviewers and proceed.
  • A review request can be updated any number of times before it has been reviewed or separate reviews can be raised using
    arc diff –create arc land
    Once a review gets accepted, the changes can be published using this command. It is the last step in the standard Differential pre-publish code review workflow. arc anoid

Extended read: arc tasks, arc browse.

Encouragement

The Phabricator command line tooling sounds little weird when we first read the documentation. But once you setup, which is very fast if you follow the documentation as it is, its very powerful. The tools are written in PHP7.X and don’t be concerned, its blazing fast. I have been extensively using it, even to review documents. ie, instead of Google Doc, Tracking via Mircorsoft word’s tracking etc.

A sample document under review.

Summary

As already mentioned, test-driven, peer-reviewed code is the only acceptable way to develop software. Code review tools like Phabricator’s inbuilt tools are highly recommended irrespective of the tooling, language that a developer is using.

How our trip to Solang Valley became “extra” adventurous

From December 26th 2018 to January 4th 2019 we were traveling and the general destination was Himachal Pradesh. The Northern, mountainous state of India. https://cdn.steemitimages.com/DQmUudGrSQYMmZdissJ9wuuoWuV4X1PZEkxYugByqX1nBZ8/image.png
Due to certain training my cousin had to attend, 4 of us travelled to New Delhi First and from there to a small city in Himachal Pradesh called Mandi. https://cdn.steemitimages.com/DQmdUscEaoT4QfTcATXRDkRT8dsGzYCZKoLFJDKHXQbe6n8/image.png

Mandi is 850 m (2,790 ft) above Mean Sea Level and for us who are traveling from “the sea Level” itself, this provided a good 1 day halt for acclimatization and rest.

(Beas River, Mandi, Himachal Pradesh, India)

Our original plan was to travel to Tirthan Valley from Mandi. But my cousin and family wanted to see snow and @firepower suggested Solang Valley as the right place. Myself was not very particular about the location and @firepower’s suggestion turned out to be very good as everyone seemed to be heading there and every weather prediction service showed snow during the time we were there.

Solang Valley


The Solang village which near Manali is where the Beas River flowing through a valley forms the valley of adventure sports – The Solang Valley. Its unbelieving crowded for a small village. One can find few hundred shops renting snow equipment, mountain bikes (ATB), couple of hundred ponys and a charade of vehicles.

As we neared Manali endless traffic block started appearing and we crawled and crossed Manali in few hours. The temperature had dropped to probably 3 or 4 degree Celcius. We had hotel booked in advance through an online service called MakeMyTrip.com & I had tried to confirm our arrival delay via SMS. There was no response from the hotel and considering it as a bad sign and seeing the unprecedented traffic I finally called the hotel. The person at the hotel was somewhere with loud music and all I could comprehend was the rooms are ready.

The adventure begins

Few minutes later, I got a call back from the hotel. The call was not audible but I felt something wrong. Tried again and after many tries the call was audible and the hotel person lazily explained that the rooms are sold out. I tried to explain I had updated them in the morning and I have a receipt from MakeMyTrip. At this point the hotel proprietor said, if we had booked the ticket through MakeMyTrip, talk to them and not to the hotel. I politely asked him to please try to talk to MakeMytrip – the hotel person wanted us to stop or go-back to Manali & take accommodation in a stay in Manali.

So, everything was crystal clear. We had booked at the hotel quite early at a nominal (yes, very nominal rate). And here we were on the Christmas – New Year season where the rates can be anything. People were probably trying to optimize their occupancy.

We never found out whose mistake it was. We only knew that we had not done anything wrong.

Sensing trouble, I asked my wife who was not traveling with me to call MakeMyTrip & arrange a call back. Simultaneously I called MakeMyTrip.com from another phone. So, after few minutes, I managed to explain the MakeMytrip representative what is going on. He agreed to check with the hotel and call back. He took the booking ID and other relevant details. So, I waited for the call back. Few minutes later the first call back arrived from MakeMyTrip & they explained, there is nothing to worry and I just have to go there and check-in the hotel. Few minutes into the conversation, the second call back arrived. The representative bluntly explained that the hotel is sold out ! So I asked him what happened to the booking we did – to which again he said, the hotel is sold out. All this while, I had the other MakeMyTrip executive on the different phone explaining that everything is in order.


Travels are one of the best teachers who gives us lessons which no one else can give


I must say, it was fun to put the executives on speaker and tell them that the calls are on recording and they are contradicting each other. This was my turn to wear the cold and bruteless hat, thus I said, “MakeMyTrip.com has offered us the hotel booking and we are now standing in near zero temperatures. We don’t have the rooms and 4 lives are in the hands of MakeMyTrip”. The representatives both agreed to help out.

Rest of the few kilometers we sat down and relaxed.

The hotel




We reached Solang Valley and entered the hotel where we had our rooms booked. The person at the reception promptly received us and he was looking into the booking details. Few moments later the owner of the hotel came and he was looking at the details as well as if nothing happened. Then, he asked in whose name the booking is – this time, I had to give the booking details. We looked at each other & with after considerable delay the hotel owner said, we spoke little while ago. I said, Yes we did. After he explaining that the rooms are sold out, I told them to talk to the online portal whose booking software had auto-magically sent me booking confirmation.

## Failed Startups helps Entrepreneurs!

This is something I realized just now while I was writing this. It so happned that I was fortunate or unfortunate to start mybusticket.com few years before a popular Indian bus ticketing service called RedBus.in and then loosing out to them. I also had adventures into travel by the name of Routez.Travel. While we waited for the call back, I was thinking about how travel industry worked, about those APIs and services which makes hotel bookings, flight bookings etc possible. Thanks to RECCAA.Club, I knew about hospitality management software as well.

The much awaited call back from MakeMytrip arrived and I must mention that the executive was professional and one of the most proactive customer care executives I have ever came across.

So, we talked about travel industry, travel booking software, acquisitions done by GoIbibo, acquisitions done by MakeMyTrip and pretty much everything about travel industry other than flight bookings!

The executive explained to me that he will try his level best to arrange a hotel either at this one or elsewhere. I handed over the phone to the the hotel owner and this time the discussions were about GoIbibo-MMT panel and “Nancy” & many other irrelevant things. The phone was back to me and I clearly said, the life of 4 of us is with MakeMyTrip. Both the hotel and the MakeMyTrip representative requested to wait for 15 minutes.

The hotel owner offered us tea & showed us 2 rooms which by then got “cancelled”. The tea was a life saver as the cold and walking on crystallized snow had started impacting me. The MakeMyTrip representative had kept his word and called back and explained a nearby hotel which was perhaps the best in the Valley. He explained even the minute details and left the decision to me. I asked him to talk to my hotel owner once again and see whether the newly appeared rooms can be arranged. As this is normal incident in touristy areas, I just wanted to play along than make a scene. The hotel owner wanted 3 times the normal price from MakeMyTrip. To my surprise, the MakeMyTrip owned the situation and offered to do anything as per my wish. I asked for the MakeMyTrip’s representative & decided to go with the hotel he suggested. He went ahead and make all the required arrangements.

When we finally walked in to the hotel that MakeMyTrip had arranged, we were surprised to find a Swiss cottage which costed 5 times our original room. The manager at “Sky one Ski” Mr Hemanth welcomed us as if to his own home & made us comfortable.

The adventure was not over!

The online Portal MakeMyTrip and its executives had done and excellent job to serve us. But our dear friend at the hotel directed to the wrong location when asked about the new location. My physical state due to the extreme weather had clouded my thinking and instead of cross checking the new hotel location we decided to walk there. Due to the confusions, we walked close to 1 km in the chilling cold over the slippery ice and reached the hotel. There was no power anywhere and after a while we realized that our “hotel” guy had sent us to a different hotel with similar name. Helpless, we walked back and found “Sky one Ski” with the help of helpful localities. Our driver was very helpful as sympathetic as well.

The Swiss Tent

Sky one Ski has marvelous facilities and well equipped Swiss Tents. The property is tucked inside an apple orchard.

(Inside the Beautiful Tent)

(The Apple Orchad)

While we had the most luxurious hotel – thanks to the travel operator – power and the climate was not the best. Unfortunately there was no power and we had only 1 tent instead of 2 rooms. We had a bunch of candles which we used to heat the tent and tucked inside the blankets (Duet) with our 3 layer clothing, jackets and gloves. The altitude though it was only 10,000 feet (3000 meters), was acting on us, the weather by then – 10 degrees presented us with a chilling experience. Thanks to the hotel guy who gave priority to few pennies over the well being of guests, there we were sleeping under the sky, in a luxurious Swiss Tent, separated from the freezing weather by 2 layers of cloth and 3 Candles.

Thanks to MakeMyTrip and the extremely helpful staff at “Sky one Ski” we woke up to another morning alive and tell this story.


(inside the swiss tent – Sky one Ski)


(The beautiful view at the morning – thanks to Mr Sivankar of MakeMyTrip.com, Mr Hemanth of Sky one Ski & Our Driver, Mr Vinod. You guys are one of the best professionals I have met & wishing you all the very best)

In the shadow of uncertainty.

From Jellikkettu, bull run/fight, 2012, Tamilnadu, India

Somehow this photo I happen to take few years ago depicts the current crytpo currency markets. I find it ironic that the bull is surging here though people say its a bear market.

The reality is that, people will gets crushed underneath even once the bull lands on the ground.


Jallikattu, aka the sport of taming the bull for a price money seemed to be our way to defeat nature, tame the beasts of uncertainty and celebrate all the good things of humanity – courage, commitment, patience valor. And yes, if one doesn’t celebrate life it does invite the wrath of Gods. We used to celebrate and had Jelikattu among many other things. Thus it happened for a thousand years. Or from the days we walked on two legs.
But, somewhere we lost the balance and what we see today is a fight for survival, the fighters don’t show valor, the bulls doesn’t feel it, they are scared. Chained and in the shadows of uncertainty, on a path nowhere both man and beast, past and the nothingness of future fights here within the double barricades.
Both men and beast looses. Nothingness wins.
inevitability. period.

From my original write up in flickr


on startup ideas : finding the niche

Somehow I find lot of people interested in product ideas end up meeting me and the ideas often surprise me either with the uniqueness or lack of it. The lack of skills and the reluctance of pick it up seems to be common trait in most of the cases. But then some people understand it and try finding mentor’s and succeed. Perhaps this will be a good idea to share some of the thoughts from personal experience.

Find a niche

I think this is one of the important aspects of succeeding with a startup idea in any area. But care must be taken to make sure that the niche will grow enough to provide the return to sustain the idea (product or service whatever the idea is). The second point it should be possible to generate enough revenue to keep going.

There 2 personal experiences of finding a niche segment and then not able to scale up : though there was a rock solid team, timelines were met etc etc.

Find a niche, boot strap and run after MONEY !

In the first example, we had a photo agency where we catered to a niche – sports photography and within the segment we focused on football. This was during the time i-league was started and we even had AIFF as client.We had a super cool name :

MangoPeel

We had award winning photographers across the country, we probably managed to publish photos faster the best, we trained photographers to upload photos, process them & we paid them probably 3 times what they used get paid. All were happy. Though all were happy, we had issues with collecting payments. After an year of operations throughout which we were break even, we had to wind it up.

Why we didn’t take off ?

I think we lacked in collecting the payments. Personally, I was too shy to ask for payments. I don’t think we were ready with money! Technically, though we had found a niche and managed to bootstrap, we couldn’t generate enough revenue to keep going. Having right skills in finance is very important. This is one point often Entreprenures overlook as they get carried away by passion. For us this was the best thing, as photography was our passion

 

 

MangoPeel is started by two young photography & travel enthusiasts who came to to know about each other through their photos. They had dreams to do things differently & courage to do it. They met at a beach side restaurant to discuss their future plans and MangoPeel was born.

MangoPeel is started by two young photography & travel enthusiasts who came to to know about each other through their photos. They had dreams to do things differently & courage to do it. They met at a beach side restaurant to discuss their future plans and MangoPeel was born.

 

about-photo-2014-11-30_11-19-04

 

Find a niche, but make sure that there is enough growth in demand

This is a particularly interesting case as this was novel & the first of its kind. We launched India’s First Web TV – IndiaVibes.TV

Once again everything was uber cool, India was about to witness a massive upgradation in internet connectivity, the magical 3G was about to get launched. Our timing looked good. We had enough programs, impressions everything looked good. But one assumption failed – the high speed internet wave didn’t take off the way we expected. This was something we never expected as projections regarding internet speed & availability at low cost miserably failed to meet the expectations. Years down the down even now the 3G connectivity is poor across the country. The writing on the wall was clear. We had wind up the show in sometime.

This was unfortunate, but I think this can happen to anyone even if everything looks good. Finding a niche & then making sure that there is enough demand is very important. If there is not enough demand, we MUST pivot and move ahead.

 

Find the niche, follow the Lean startup approach & launch fast. I think this needs an elaborate post & will talk about this in another post.

 

Raising funds are easier now with the token based economy and its a good idea if you can make use of the current Eco-system to find seed money.

What is stored in a blockchain ?

information!

Understanding the type of information stored in the blockchain will help us to decide how to implement Oracles means for  the cross chain communication etc.

A blockchain is a Distributed OpenLedger of Records Contracts & Transactions between multiple parties.

Records = Assets, People, In Game assets, Non Fungible Assets, a real world farm.


Contracts = A transfer of an asset (say, a farm) between 2 people can be depicted in a contract. In the real world a contract will be defined in a legal language. Various laws of the state will become applicable. In the context of a blockchain, a contract will be written in a “Smart Contract Language.” Blockchains that support contracts have their own language constructs applicable only in their respective context.


Transactions = The action of transferring an asset, or an action on a unique address or transfer of value is defined as a transaction in the context of a blockchain.

Kerala House Boats – Engine, Kitchen etc.

From Sun's makeup box | സൂര്യ ദേവന്റെ കണ്ണാടി.

House Boats, Aleppey, Kerala

 

Needless to say, the house boats of Kerala, to be precise in Alleppey is quite popular and attracts lots of tourists. I was curious about the the engine and other finer details, I could find in a trip and here it is:

 

The hidden engine room door in the kitchen

The hidden engine room door in the kitchen of the house boat

Engine

Engine

 

from the engine room

turning the engine - kerala house boat

turning the engine – kerala house boat

electrical wiring, plumbing and septic tank

electrical wiring, plumbing and septic tank

 

 

 

me fishing!

Its been sometime since I wanted to try my luck with fishing again – that means, during my lower primary school days I used tail along Kurichya friends in Wayanad and they used to let me cast the “choonda” with earth worm bait and once or twice gave me their knife with which I hit the water and nothing happened. So, Yesterday, we decided that enough is enough & we will get choonda again. Armed with earth worms, we bought that stick with hooks, went to nearby backwaters, alas in 10 minutes we got 2 fishes.

Now all inspired we went back and bough a bigger stick, oh, fishing raad. Then the class began. The guy at the shop is a champ with this stick ! Poor me. I just wanted to catch fish and now I have this graphite stick, “flow”, a rotating whatever for the “line” with 3 bearings, swivel (2 level one to be specific), clip / lock, I took the lessons well. Oh yea, got few led balls as weight too.

Oh the most important part is “Loore” – this fish like thing is to fool fishes. People claim that the fishes are foolish enough to hit sorry, “bait harder or faster”. I think I already know how to cast this thing – thanks to the “mooppan” who had the patience to teach me this.

After paying for this stick, which was a hefty sum, went to the earlier spot from where we got 2 fishes, successfully casted in the second try, casted again, again, finally realised that the fishes are not foolish enough to be “lured” into. And earth worms may work better. Or may be the fishes are foolish and they don’t know to deal with sophisticated sticks.

Never knew that this fishing thing is a hobby where people talk about the size of their “sticks”, weight it can handle, swivel, clip, lock, line, flow – these seems to be status symbols. (almost like people flaunting their cars, FX cameras, 1.2f 50mm lenses blah blah). Anyways, here I am with 2 fishing rods, one which can catch fishes with live baits, ie earth worms and another super sophisticated stick with even the fishes not understand.

If anyone in an around kochi knows where these ultra sophisticated fishes who understands, loore and other stuff, please do let me know !