How to measure code complexity in powershell? - powershell-2.0

We have a bunch of complex code in power shell which we are simplifying. Looking for
tools on measuring the code complexity .
that can be integrated in VSO build system to keep it under control.
Thanks, Lakshay

https://mathieubuisson.github.io/measuring-powershell-code-complexity/ this one seems to be a good solution. In the process of trying it out.

Related

Automating Speed Tests on Merging Pull Requests

I am trying to track the page speed of certain urls of my project on each merging of the pull requests in Github and output the results of report in HTML format or JSON file. On the CI side, I am going to use Jenkins. I have no prior knowledge on performance testing. I want to know about the best approach to automate the speed test, integrate it with Jenkins and output the result.
On researching over the internet, I noted few possibilities which could be done to achieve this goal.
Installing "Page Speed Insights (psi) node package", creating the script that uses the psi for fetching the speed of certain pages, generating the test reports for use with Jenkins. (Referred to this link by Oxagile)
Performance testing using Jmeter and integrating with Jenkins.
Performance analysis using LightHouse. (Referred to this link by Timo Stollenwerk)
Choosing the right approach is very important. Therefore, I would be very grateful if anyone can suggest me different approaches and thus the right one to use(with examples if possible)in my case to achieve this goal.
Thank you in advance.
After quite a bit of research, I found out that sitespeed.io is the best solution for achieving this goal. It is a complete web performance tool that helps us to measure the performance of the website. It is best for running in the continuous integration to find web performance regressions on commits and monitoring them in production and alerting on regressions.

Xilinx ISE build time and already compiled modules

Is there a way to speed up Xilinx ISE build process? I have multiple verilog HDL files in my project. Sometimes I implement a minor change in at a place in one file. However the build time is same as if the whole project were changed. I think software does not offer any advantage for already build modules.
I know its hardware, but is there some way out. I am really trouble with my slow progress. Any other tips to make the process will be appreciated.
Yours Truely
Abu Bakar
There are quite a few things you can do to speed up an FPGA build. Among them:
- floorplanning
- design partitioning (Xilinx and Altera have some differences)
- adding false paths and mulitcycle paths constraints
- playing with synthesis and physical implementation tool options
- choice of the reset scheme can also affect the build time
- not over-constraining timing
I discuss this very topic in more detail in my book.
Thanks.
You can partition the design to help speed up the place and route process in a large design. But to be honest, FPGA builds are always going to be pretty lengthy :(
That's why most of us start out doing builds and debugging on the bench and very quickly move to debugging the code in a simulator (which is very fast to compile - seconds), and only when it works there doing the loooong build for silicon (hours).

How to refactor a Delphi unit with 10000 lines with no documentation?

I have been assigned the task to refactor a Delphi unit. Wow. 10000 lines of code, no documentation, tons of copy and paste code.
THere are many methods made with copy and paste that could be refactored, anyway I am lost in all those lines, I have the interface section where I can "find my way", but in general what do yuo suggest for tackling this kind of task?
Thanks.
Get yourself a copy of Working Effectively with Legacy Code by Michael Feathers. It has all kinds of techniques for safely refactoring code to get it running under a test framework. Examples are mostly in Java and C++ but should be easy enough to figure out.
Install a third-party refactoring tool (or multiple) such as CodeRush for Delphi(sadly no longer developed), Castalia or ModelMaker Code Explorer. Delphi has some refactoring support built in but in my experience it is too limited and tends to choke on very large code bases.
Buy a copy of Simian. It doesn't have direct support for Object Pascal but its plain text parser works well enough. If enough people request support for Object Pascal I'm sure they'd add it. I haven't found any other code duplication detection tool as capable as Simian.
I would also recommend bookmarking http://www.refactoring.com/catalog/ and http://www.industriallogic.com/xp/refactoring/catalog.html.
It also wouldn't hurt to get a copy of Clean Code: A Handbook of Agile Software Craftsmanship by Robert "Uncle Bob" Martin et al. It's easy to recognize bad code. It's much harder know when you're writing good code.
A word of caution: Focus on refactoring the code you need to work on. Its easy to start down the rabbit hole and wind up spending months refactoring code that wasn't immediately relevant to the task at hand.
And save your self some trouble. Don't try to "fix" code and refactor it at the same time. Refactor first, then fix bugs or add that new feature. Remember, refactoring is modifying without changing external behavior.
Resist the urge to attempt a complete rewrite. I learned the hard way that crappy code that meets the user's requirements is preferable to clean code that doesn't. Crappy code can always be incrementally improved until its something to be proud of.
I think the best thing you can do is to write DUnit Tests for the interface. It forces you to understand the existing code, helps during debugging and it ensures that the interface acts the same after refactoring.
The Top 12 Reasons to Write Unit Tests apply perfectly in your case:
Tests Reduce Bugs in New Features.
Tests Reduce Bugs in Existing Features.
Tests Are Good Documentation.
Tests Reduce the Cost of Change.
Tests Improve Design.
Tests Allow Refactoring.
Tests Constrain Features
Tests Defend Against Other Programmers
Testing Is Fun
Testing Forces You to Slow Down and Think
Testing Makes Development Faster
Tests Reduce Fear (Fear of change, Fear of breakage, Fear of updates)
I've faced similar situations. My condolences to you!
In my opinion, the most important thing is that you actually understand all the code as it is today. Minds better than mine may be able to simply read the code and understand it. However, I can't.
After reading the code for a general overview, I usually repeatedly single step through it in the debugger until I begin to see some patterns of operation and recognize code that I've read before. Maybe this is obvious, but thought I'd mention it.
You might also think about creating a good test suite that runs on the current code.
Does the interface section contain a bunch of class definitions? If so, create a new unit for every class and move each class to it's own unit.If you use Delphi 2007 or better, you can use the "refactor/Move" option to move those classes to the new (namespace) units.The next step is splitting the large classes into smaller classes. That's just a lot of manual work.Once your code is divided over multiple units, you can examine each unit, detect identical code and generate base classes that would be used as parent for the two classes that share similar functionality.
In addition of understanding the code etc, these tools may help refactoring and reorganizing the project:
Model Maker is powerful design, reverse-engineer and refactoring tool: http://www.modelmakertools.com/modelmaker/index.html
Model Maker Code Explorer is powerful plugin for Delphi IDE to help with refactoring, code navigation etc: http://www.modelmakertools.com/code-explorer/index.html
I would use some sort of UML tool to generate som class diagrams and other diagrams to get an overview of the system, and start splitting up and commenting like #Workshop Alex said.
Use a tool like Doxygen to help you map the code.
Help on that is here
Start out small and eventually do a partial or full rewrite. Start creating base classes to accomplish pieces of the puzzle without changing the output. Rinse-repeat until you have a new, supportable codebase.
Once you hit those copy-n-paste routines, you'll have base classes to do the work and it'll really help accelerate the task.

Make recommendations on building (or setting up) an RRD Tool based web app for website monitoring that is simpler than Cacti?

I think Cacti is great except for the fact that it takes hours to configure it. There is a lot that you can do with it but I find it a little overly complicated. A script collecting disk utilization recently broke on me (for no apparent reason), I spent 3 hours and got no where.
I would like a tool like Cacti but super easy to setup. I have some familiarity wit RRD so a little bit of manual work is okay.
To make this more programming related: An alternative to a different software package would be to develop something custom built. Has anybody attempted this? What pieces to you use to built which parts?
There are a slew of tools out there:
Cacti
Ganglia
Zabbix
Hyperic
Monit
Reconnoiter
Graphite
Each focus on different aspects of usability. Reconnoiter and Graphite were born out of specialized needs and wanting greater resolution than RRD can provide.
I suggest you do take another look at Cacti before building yourself. Create templates in cacti for your hosts and your graphs. Then use the built in CLI tools to automate. This way for each host, you do not need to click through the GUI.
I think this is what I want:
http://collectd.org
Collectd in combination with drraw looks like it will fit my needs.
I don't know if this will meet your needs, but you might also want to look at RRDUtil:
http://www.tnpi.biz/internet/manage/rrdutil/
Unfortunately they are all very time-consuming to learn and configure. You have to spend time to understand all the principles used and read sample configurations.
No short-cuts on this chore :-D
We use gmond and ganglia.

Worth migrating to Rake?

Is it really advantageous to move to Rake from ant?
Anyone migrated from ant and find something monumental?
FYI: Current environment is Ant for J2ME builds
I would say yes, but I have a different perspective than a Java-environment guy, because I'm a .NET-environment guy. I had written and maintained a non-trivial build script (clean, generate-assembly-info, build, test, coverage, analysis, package) in msbuild (MS' XML-driven NAnt effort) and it was very painful:
XML isn't friendly; it's very noisy
No-one else on the team was interested in learning it to the point of performing more, and more useful, automations; so high bus factor (ie, if I get hit by a bus, they're stuck with it)
It did not lend itself to refactoring or improvement - it was one of those 'touch-at-your-peril' things, you know?
It needed custom C# tasks to be written to run the various tools the build needed (though to be fair, often these are written by the vendors)
In about a work-week's worth of my time (got to love empty offices at Christmas time!), I've learned enough ruby+rake to replace the whole thing with a shorter (in terms of LOC) script with slightly more functionality, and more understandability (I hope, anyhow; haven't had it reviewed yet).
It benefits from:
- It's a new language, but a real language. My team-mates like learning new languages, and this, while a thin excuse, is still an excuse ;-) This might mitigate the bus-factor if I'm right.
- It's a short hop (I gather) from here to capistrano, the automated/remote/distributed deployment tool from the RoR world. Despite being an MS-stack shop, we're gonna be using that in combination with IIS7 finally having a CLI config tool.
So, yeah. Your mileage may vary, but it was worth it for me.
Rake is great if you want:
Access to a real programming language; conditionals and loops are all dead-simple, compared to Ant (in which they are nigh-impossible)
File format that is easy to read and can be syntax checked
More intuitive/predictable assignment of values to variables
Rake is bad for you because:
You need to provide a lot basic of the tasks (like running javac, creating jar files, etc.) yourself. Projects like Raven might help, but it seems geared toward auto-downloading dependencies and not so much automated a build/deploy process. Plus, the documentation is a bit lacking.
Most java tools that can be automated are done as Ant tasks, which aren't easily runnable from Rake; starting up the JVM can be annoying at build time
You might want to check out buildr as well. It's a higher-level build-tool built on rake. IMHO it takes a lot of the good features from maven, and throws away the bad-ones. I haven't used it in anything big myself but I know people who have and are quite happy with it.
Another tool that you might want to check out is Gant if ant isn't meeting your needs. It adds full blown scripting support to ant but allows you to re-use your ant tasks as needed. It really depends on what you don't like about ant.

Resources